首页 > 代码库 > 对List<Map<String, Object>>集合排序

对List<Map<String, Object>>集合排序

 

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);      }

 

对List<Map<String, Object>>集合排序