实现对Map按照value升序排序
/** * 实现对map按照value升序排序 * @param map * @return */public static List<Entry<Object, Object>> getSortByValue(Map map) {Set<Entry<Object, Object>> set = map.entrySet();List<Map.Entry<Object, Object>> list = new ArrayList<Map.Entry<Object, Object>>(set);Collections.sort(list, new Comparator<Map.Entry<Object, Object>>() {public int compare(Map.Entry<Object, Object> obj1,Map.Entry<Object, Object> obj2) {return ((String) obj1.getKey()).compareTo((String) obj2.getKey());// 按key降排序// return (Integer)obj1.getValue() - (Integer)obj2.getValue();//按value升序排序// return (Integer)obj2.getValue() - (Integer)obj1.getValue();//按value降序排序}});return list;}?