Map按值排序的方法,Map值排序方法,/** * Map 按值
分享于 点击 20992 次 点评:184
Map按值排序的方法,Map值排序方法,/** * Map 按值
/** * Map 按值(value)排序 * @param map* @return Map.Entry[] */public static Map.Entry[] getSortedHashtableByValue(Map<String, Integer> map) { Set set = map.entrySet(); Map.Entry[] entries = (Map.Entry[]) set.toArray(new Map.Entry[set.size()]); Arrays.sort(entries, new Comparator() { public int compare(Object arg0, Object arg1) { Long key1 = Long.valueOf(((Map.Entry) arg0).getValue().toString()); Long key2 = Long.valueOf(((Map.Entry) arg1).getValue().toString()); return key1.compareTo(key2); } }); return entries; }//该片段来自于http://byrx.net
用户点评