现在的位置: 首页 > 综合 > 正文

Map根据值排序

2014年09月05日 ⁄ 综合 ⁄ 共 416字 ⁄ 字号 评论关闭

 Map<Integer, String> allCountryMap = tripPlaceManager.getAllCountryMap();
    List<Map.Entry<Integer, String>> countryList = new ArrayList<Map.Entry<Integer, String>>(allCountryMap.entrySet());
    Collections.sort(countryList, new Comparator<Map.Entry<Integer, String>>() {
        public int compare(Map.Entry<Integer, String> obj1, Map.Entry<Integer, String> obj2) {
          return obj1.getValue().compareTo(obj2.getValue());
        }
      });

抱歉!评论已关闭.