java how to sort custom objects in descending orde

Solutions on MaxInterview for java how to sort custom objects in descending orde by the best coders in the world

showing results for - "java how to sort custom objects in descending orde"
Diego
12 Feb 2016
1ArrayList<StudentInformation> infos = new ArrayList<StudentInformation>();
2// fill array
3Collections.sort(infos, 
4    Comparator.comparingInt(StudentInformation::getBirthYear).reversed());
5
Eddy
17 Nov 2018
1ArrayList<StudentInformation> infos = new ArrayList<StudentInformation>();
2// fill array
3Collections.sort(infos, (s1, s2) ->
4    Integer.compare(s2.getBirthYear(), s1.getBirthYear()));
5