对Map的key按升序进行排序
//对Map的key按升序进行排序 List<Map.Entry<Integer,Task>> mappingList = new ArrayList<Map.Entry<Integer, Task>>(map.entrySet()); Collections.sort(mappingList, new Comparator<Map.Entry<Integer, Task>>() { @Override public int compare(Entry<Integer, Task> o1, Entry<Integer, Task> o2) { return o1.getKey().compareTo(o2.getKey()); } }); for (Map.Entry<Integer, Task> mapping : mappingList) { result.add(mapping.getValue()); }