InterviewBit-Java-Solutions icon indicating copy to clipboard operation
InterviewBit-Java-Solutions copied to clipboard

I have query in Hashing/Equal.java

Open chaudharisuresh997 opened this issue 6 years ago • 0 comments

Hi Varun Thanks alot for sharing such clean and easy to understand solution, Can you please explain what this sorting comparator class will be doing. what purpose does it solve I hope i am not asking too much but if you could give line by line comment to the comparator class code that will be great. I am refering to the below code. class sort implements Comparator<ArrayList<Integer>> {

@Override
public int compare(ArrayList<Integer> o1, ArrayList<Integer> o2) {
	int c = o1.get(0).compareTo(o2.get(0));
	if (c == 0) {
		c = o1.get(1).compareTo(o2.get(1));
	}
	if (c == 0) {
		c = o1.get(2).compareTo(o2.get(2));
	}
	if (c == 0) {
		c = o1.get(3).compareTo(o2.get(3));
	}
	
	return c;
}

}

chaudharisuresh997 avatar Sep 21 '19 17:09 chaudharisuresh997