您好,我可以帮助我解决我的排序问题
HashMap<String, Integer> hm = new HashMap<String, Integer>();
hm.put("Berkan Cetin", 100);
hm.put("Mahmut Koca", 78);
hm.put("Rifat Sarili", 89);
hm.put("Cagdas Polat", 61);
hm.put("Gulay Uygun", 56);
例如,如果我想按键排序,我可以使用TreeMap
或者其他,但我无法根据值找到从最大到最小Integer
排序的方法。
谢谢
答案 0 :(得分:1)
您可以执行new TreeSet<String>(map.keySet())
之类的操作来获取一组有序的密钥..
地图本身不是您要分类的东西。