Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// source: http://java.dzone.com/articles/using-lambda-expression-sort
// sort by first name
people.sort((p1, p2) -> p1.firstName.compareTo(p2.firstName));
// sort by full name
String fullName(Person p) { return p.firstName + " " + p.lastName; }
people.sort((p1, p2) -> fullName(p1).compareTo(fullName(p2)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment