//先根据姓名分组再根据分数排序 Map<String, List<Student>> map1 = listAll.stream().collect( Collectors.groupingBy(Student::getName, HashMap::new, Collectors.collectingAndThen(Collectors.toList(), //正序 list -> list.stream().sorted(Comparator.comparing(Student::getScore)) //倒序 //list -> list.stream().sorted(Comparator.comparing(Student::getScore).reversed()) .collect(Collectors.toList()) )));
标签:Collectors,stream,list,分组,Student,排序,java8 From: https://www.cnblogs.com/wj123bk/p/17185268.html