List集合里面是map类型进行排序

    技术2022-07-20  96

    List集合里面是map类型进行排序

    1.根据用户浏览量进行排序 例: List<Map<String,Object>> mapList= new ArrayList<>(); 注:mapList里面存在 browserNum属性 //排序 倒序 if (mapList != null && mapList .size() > 1) { Collections.sort(mapList , new Comparator<Map<String, Object>>() { @Override public int compare(Map<String, Object> o1, Map<String, Object> o2) { Integer o1Value = Integer.valueOf(o1.get("browserNum").toString()); Integer o2Value = Integer.valueOf(o2.get("browserNum").toString()); return o1Value.compareTo(o2Value); } }); } return mapList; 想要倒序的话可以调换一下返回值
    Processed: 0.013, SQL: 9