java8 分组排序
//先根据姓名分组再根据分数排序 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()) )));
浙公网安备 33010602011771号