private void sort(List<Map<String, Object>> list) { Collections.sort(list, new Comparator<Map<String, Object>>(){ public int compare(Map<String, Object> o1, Map<String, Object> o2) { //依据map中某个字段,从小到大排序 return (Integer)o1.get("num")>(Integer)o2.get("num")?1:( (Integer)o1.get("num")==(Integer)o2.get("num")?0:-1); } }); }
时间: 2024-12-13 01:03:45