what is comparator in Java
Hierarchy package: java.util.Comparator Definition Sorting interface that designed for mutiple special conditions by creating compare method. For example, you can sort list in ascending order of size and descending order of letters. about the compare() method if compare() method return positive number, swap the input parameters else will be remain same condition return First parameter < second parameter negative First parameter == second parameter 0 First parameter > second parameter positive How to use MyComparator implements Comparator<>