Created
March 7, 2016 14:58
-
-
Save sadedv/ccb46bf43d6f883046f8 to your computer and use it in GitHub Desktop.
Comparator
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
List<Person> persons = personsExtracter.getPersons(); | |
Collections.sort(persons, new AgeComparator()); | |
public class AgeComparator implements Comparator<Person> { | |
@Override | |
public int compare(Person o1, Person o2) { | |
Integer age1 = o1.getAge(); | |
Integer age2 = o2.getAge(); | |
return age1.compareTo(age2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment