Skip to content

Instantly share code, notes, and snippets.

@alexo
Created December 13, 2012 20:48
Show Gist options
  • Save alexo/4279707 to your computer and use it in GitHub Desktop.
Save alexo/4279707 to your computer and use it in GitHub Desktop.
Collections.sort(people, new Comparator<Person>() {
public int compare(Person a, Person b) {
return a.getName().compare(b.getName());
}
});
Collections.sort(people, new Comparator<Person>() {
public int compare(Person a, Person b) {
return Integer.valueOf(a.getAge()).compare(b.getAge());
}
});
val sortedPeople = people.sortBy(p => (p.name, p.age))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment