📜  collections.sort 自定义比较器 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:28.333000             🧑  作者: Mango

代码示例1
ArrayList employees = getUnsortedEmployeeList();
             
Comparator compareById = (Employee o1, Employee o2) -> o1.getId().compareTo( o2.getId() );
 
Collections.sort(employees, compareById);
 
Collections.sort(employees, compareById.reversed());