根据Hash值排序的,无序排序的
List<ModuleVo> moduleList=new ArrayList();
Map<Integer, List<ModuleVo>> collectResult = moduleList.stream().collect(Collectors.groupingBy(ModuleVo::getProjectId));
根据time进行升序排序,如下
TreeMap<Integer, List<ModuleVo>> collectResult = moduleList.stream().collect(Collectors.groupingBy(ModuleVo::getTime,TreeMap::new,Collectors.toList()));
TreeMap默认按照key升序排序
descendingMap()降序排序
TreeMap<Integer, List<ModuleVo>> collectResult = moduleList.stream().collect(Collectors.groupingBy(ModuleVo::getTime,TreeMap::new,Collectors.toList())).descendingMap();