private void mySort(List<Map<String, Object>> list) { //list为待排序的集合,按SEQ字段排序 Comparator<Map<String, String>> mapComprator = new Comparator<Map<String, String>>() { @Override public int compare(Map<String, String> o1, Map<String, String> o2) { if (Integer.valueOf(o1.get("SEQ").toString()) > Integer.valueOf(o2.get("SEQ").toString())) { return 1; //此处是按降序排序 } else { return -1; } } }; Collections.sort((List)list, mapComprator); }
时间: 2024-11-10 10:53:18