1.按单个字段排序
list.stream().sorted(Comparator.comparing(User::getAge)).collect(Collectors.toList());
2.按多个字段排序
//age升序
Comparator byIdASC = Comparator.comparing(Student::getAge);
//named不分区大小写降序
Comparator byNameDESC = Comparator.comparing(Student::getName,String.CASE_INSENSITIVE_ORDER).reversed();
//birthday 降序
Comparator byBirthdayDESC = Comparator.comparing(Student::getBirthday).reversed();
//联合排序
Comparator finalComparator = byIdASC.thenComparing(byNameDESC).thenComparing(byBirthdayDESC);
List<Student> result = stuList.stream().sorted(finalComparator).collect(Collectors.toList());