Created
March 21, 2014 12:29
-
-
Save shaunlebron/9685175 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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