//对集合进行筛选后再使用collect()方法把集合转成list List<EsenResultDayThreeHistogram> list1 = list.stream().filter(e -> e.getGraphType().equals(Constants.GROUP_TYPE_NUM)) .collect(Collectors.toList()); //对list进行分组,求和。 Map<String,Integer> map2 = list1.stream().collect(Collectors.groupingBy(EsenResultDayThreeHistogram::getyType, Collectors.summingInt(EsenResultDayThreeHistogram::getsCount))); //对map里的value进行排序 List<Map.Entry<String,Integer>> entryArrayList = new ArrayList<>(); entryArrayList.addAll(map2.entrySet()); Collections.sort(entryArrayList, (o1, o2) -> o2.getValue()-o1.getValue());