java8 的map 排序 public class test { public static void main(String args[]) { List<Map<String,String>> mpList = new ArrayList<>(); Map<String,String> mp ; mp = new HashMap<>(); // 每个map都包含两个元素:name & score mp.put("name","Mike"); mp.put("score","80.0"); // 将所有的map都存入mpList列表中 mpList.add(mp); mp = new HashMap<>(); mp.put("name","Amy"); mp.put("score","90"); mpList.add(mp); mp = new HashMap<>(); mp.put("name","John"); mp.put("score","60"); mpList.add(mp); // 下面是排序,score:大->小 mpList.sort((a1,a2)->((Double.valueOf(a1.get("score")).compareTo(Double.valueOf(a2.get("score")))))); System.out.println(mpList); } }