Skip to content

Instantly share code, notes, and snippets.

@sadedv
Created March 7, 2016 14:58
Show Gist options
  • Save sadedv/ccb46bf43d6f883046f8 to your computer and use it in GitHub Desktop.
Save sadedv/ccb46bf43d6f883046f8 to your computer and use it in GitHub Desktop.
Comparator
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