1、list分组:
Map<String,List<AlarmStatisticalDO>> map = alarmStatisticalDOList.stream().collect(Collectors.groupingBy(a -> a.getAlarmDate())); for (String alarmDateStr:map.keySet()) { List<LibAlarm> libAlarmList = new ArrayList<>(); List<AlarmStatisticalDO> alarmStatisticalDOS = map.get(alarmDateStr); .... }
2、list排序:
List<LibAlarm> libAlarms = libAlarmList.stream().sorted(Comparator.comparing(LibAlarm::getAlarmCount).reversed()).collect(Collectors.toList());//倒序