Java 中List<Map<String,String>>排序问题

Java 中List<Map<String,String>>排序问题

public static void mapSorts(List<Map<String, String>> map) {
    
    
    Collections.sort(map, new Comparator<Map<String, String>>() {
    
    

        @Override
        public int compare(Map<String, String> o1, Map<String, String> o2) {
    
    
            // TODO Auto-generated method stub
            if (Double.parseDouble(o1.get("sumall").toString())>Double.parseDouble(o2.get("sumall").toString()) ) {
    
    
                return -1;
            }
            return 1;
        }
    });
}

猜你喜欢

转载自blog.csdn.net/firstlt0217/article/details/121297731
今日推荐