List<Map<String,String>> rsInfoList = new ArrayList<Map<String,String>>(); Map<String,String> key = new HashMap<String,String>(); key.put("NO", "2"); key.put("NAME", "AAA"); rsInfoList.add(key); key = new HashMap<String,String>(); key.put("NO", "3"); key.put("NAME", "BBB"); rsInfoList.add(key); key = new HashMap<String,String>(); key.put("NO", "1"); key.put("NAME", "CCC"); rsInfoList.add(key); System.out.println("排序前:"+rsInfoList); //根据NO字段进行排序 Collections.sort(rsInfoList, new Comparator<Map<String, String>>() { public int compare(Map<String, String> o1, Map<String, String> o2) { return o2.get("NO").compareTo(o1.get("NO")); } }); System.out.println("排序后:"+rsInfoList);
结果: