首页 > 其他分享 >List<Map<String,Object>> allList = new ArrayList<>(); 针对Object进行 List 排序

List<Map<String,Object>> allList = new ArrayList<>(); 针对Object进行 List 排序

时间:2022-12-19 16:00:10浏览次数:49  
标签:BigDecimal ArrayList Object List allList name2 name1 new

List<Map<String,Object>> allList = new ArrayList<>();

Collections.sort(allList, new Comparator<Map<String, Object>>() {
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
BigDecimal name1 = new BigDecimal(o1.get("value").toString()) ;//name1是从你list里的第一个name
BigDecimal name2 = new BigDecimal(o2.get("value").toString()) ;//name2是从你list里的第二个name
return name2.compareTo(name1);
}
});

标签:BigDecimal,ArrayList,Object,List,allList,name2,name1,new
From: https://www.cnblogs.com/wangqunye/p/16992389.html

相关文章