hashmap排序

来源:互联网 发布:gre数学难吗 知乎 编辑:程序博客网 时间:2024/06/05 02:55
HashMap<Integer,ClassGroupModel> hashS1=new HashMap<Integer, ClassGroupModel>();

//遍历有效公司的排序ArrayList<Map.Entry<Integer,ClassGroupModel>> listG= new ArrayList<Map.Entry<Integer,ClassGroupModel>>(hashS1.entrySet());Collections.sort(listG, new Comparator<Map.Entry<Integer, ClassGroupModel>>() {    public int  compare(Map.Entry<Integer, ClassGroupModel> o1,                        Map.Entry<Integer, ClassGroupModel> o2) {        return (new Double(o2.getValue().getOwnerEquity()).intValue()- new Double(o1.getValue().getOwnerEquity()).intValue());    }});
ps:o2-o1  倒序      o1-o2 正序     进行排序的值必须要是int类型