List按某个字段排序
程序员文章站
2022-03-23 22:11:41
...
https://blog.csdn.net/github_39325328/article/details/89397264
List<User> newList = list.stream().sorted(Comparator.comparing(User::getAge))
.collect(Collectors.toList());
List<User> listSort = list.stream().sorted(Comparator.comparing(User::getAge).reversed().thenComparing(User::getScore)).collect(Collectors.toList());
List<User> newList = list.stream().sorted(Comparator.comparing(User::getAge))
.collect(Collectors.toList());
List<User> listSort = list.stream().sorted(Comparator.comparing(User::getAge).reversed().thenComparing(User::getScore)).collect(Collectors.toList());
上一篇: Spring声明式事务原理解析