Created
December 15, 2016 14:46
-
-
Save khan5v/6bc76df08aab271badc01630aa2aff88 to your computer and use it in GitHub Desktop.
Java comparator usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collections.sort(list, new Comparator<Pair>() { | |
public int compare(Pair p1, Pair p2) { | |
//Reverse order of i (integers) and lexicographic order of s (strings) | |
return p1.i < p2.i ? 1 : p1.i > p2.i ? -1 : p1.s.compareTo(p2.s); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment