Answers for "collections.sort custom comparator"

1

collections.sort custom comparator

ArrayList<Employee> employees = getUnsortedEmployeeList();
             
Comparator<Employee> compareById = (Employee o1, Employee o2) -> o1.getId().compareTo( o2.getId() );
 
Collections.sort(employees, compareById);
 
Collections.sort(employees, compareById.reversed());
Posted by: Guest on June-28-2020

Code answers related to "collections.sort custom comparator"

Browse Popular Code Answers by Language