Created
August 20, 2016 16:29
-
-
Save iammert/b9b67fff96aa3c0fe3c5f6b1711d6e63 to your computer and use it in GitHub Desktop.
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
public class DataProvider { | |
public static List<Person> getOldPersonList(){ | |
List<Person> persons = new ArrayList<>(); | |
persons.add(new Person(1, 20, "John")); | |
persons.add(new Person(2, 12, "Jack")); | |
persons.add(new Person(3, 8, "Michael")); | |
persons.add(new Person(4, 19, "Rafael")); | |
return persons; | |
} | |
public static List<Person> sortByAge(List<Person> oldList){ | |
Collections.sort(oldList, new Comparator<Person>() { | |
@Override | |
public int compare(Person person, Person person2) { | |
return person.age - person2.age; | |
} | |
}); | |
return oldList; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment