您的位置:首页 > 其它

hashmap排序

2017-10-17 16:39 232 查看
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类型 

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  hashmap