Map按照值降序排列

来源:互联网 发布:双敏网络精灵 编辑:程序博客网 时间:2024/05/29 06:31
List<Map.Entry<String, Long>> entryList = new ArrayList<Map.Entry<String, Long>>(ruleMap.entrySet()); Collections.sort(entryList, new Comparator<Map.Entry<String, Long>>() {    @Override    public int compare(Entry<String, Long> o1, Entry<String, Long> o2) {        return o2.getValue().compareTo(o1.getValue());    }});for(Map.Entry<String, Long> entry : entryList) {    xAxis.add(entry.getKey());    series.add(entry.getValue());}
0 0
原创粉丝点击