Skip to content

Instantly share code, notes, and snippets.

@khan5v
Created December 15, 2016 14:46
Show Gist options
  • Save khan5v/6bc76df08aab271badc01630aa2aff88 to your computer and use it in GitHub Desktop.
Save khan5v/6bc76df08aab271badc01630aa2aff88 to your computer and use it in GitHub Desktop.
Java comparator usage
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