网站首页
编程语言
数据库
系统相关
其他分享
编程问答
collectResult
2024-07-24
使用stream对集合进行排序
根据Hash值排序的,无序排序的List<ModuleVo>moduleList=newArrayList();Map<Integer,List<ModuleVo>>collectResult=moduleList.stream().collect(Collectors.groupingBy(ModuleVo::getProjectId));根据time进行升序排序,如下TreeMap<Integer,List<ModuleVo>