java8的List排序
示例1:从小到大,正序排序 List<Student> sList = studentList.stream().sorted(Comparator.comparing(Student::getId)).collect(Collectors.toList()); 示例2:倒序 List<Student> sList = studentList.stream().sorted(Comparator.comparing(Student::getId).reversed()).collect(Collectors.toList());
版权声明:本文为sunyufeng22原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。