编程语言
首页 > 编程语言> > Java8之list排序

Java8之list排序

作者:互联网

1,List<Map<String,Object>>格式

//排序
        Comparator<Map<String, Object>> comparator = Comparator.comparing(item -> item.get(sortField).toString());
        if (Constant.SORT_TYPE_ASC == sortType){
            //升序
            resourceList.sort(comparator);
        }else {
            resourceList.sort(comparator.reversed());
        }

2,List<Model>格式

resultList.sort(Comparator.comparing(MetaDataModel::getOrder));
dictVoList.sort(Comparator.comparingInt(DictVo::getOrder));

 

标签:sort,comparator,Comparator,List,list,comparing,resourceList,排序,Java8
来源: https://www.cnblogs.com/cailijuan/p/10687698.html