sort descending java list object code example
Example 1: java how to sort custom objects in descending orde
ArrayList<StudentInformation> infos = new ArrayList<StudentInformation>();
Collections.sort(infos,
Comparator.comparingInt(StudentInformation::getBirthYear).reversed());
Example 2: java how to sort custom objects in descending orde
ArrayList<StudentInformation> infos = new ArrayList<StudentInformation>();
Collections.sort(infos, (s1, s2) ->
Integer.compare(s2.getBirthYear(), s1.getBirthYear()));