java map value 排序
2016-01-14 16:04
465 查看
java map value 排序
Map<String, Integer> map = new HashMap<String, Integer>(); map.put("1b-", Integer.valueOf(78)); map.put("4a-", Integer.valueOf(34)); map.put("cc-", Integer.valueOf(999)); List<Entry<String,Integer>> list = new ArrayList<Entry<String,Integer>>(map.entrySet()); Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() { public int compare(Map.Entry<String, Integer> o1,Map.Entry<String, Integer> o2) { return (o2.getValue() - o1.getValue()); } }); for (Entry<String, Integer> entry : list) { System.out.println(entry.getKey()+":"+entry.getValue()); }
相关文章推荐
- iOS --- UITabbar 显示小红点 (消息提示)
- UITableView隐藏多余的分割线
- Android UI基础之GrideView的使用
- 什么是baseline?release和build
- 改变Label不同的字显示不同的颜色
- NSData与UIImage之间的转换
- lazy懒加载(延迟加载)UITableView
- HDU5146Sequence
- 使用搜索条UISearchBar 谓词实现搜索的判断
- Pop3_解决PKIX:unable to find valid certification path to requested target 的问题
- iOS开发之:dispatch_async 与 dispatch_get_global_queue 的使用方法
- WPF Issues
- Ubuntu出现error:unknown filesystem grub rescue解决办法
- Maven多个mudule只编译、打包指定module
- UGUI中将图片转换成精灵Sprite
- [FAQ14053]L1下拉状态栏QuickSetting没有数据连接
- 使用CAShapeLayer和UIBezierPath绘制色盘
- 解决“Dynamic Web Module 3.0 requires Java 1.6 or newer.”错误
- 从iOS手雷出发-总结iOS多设备UI适配规范方案
- 源码推荐(01.14B):AFN网络请求一句代码搞定,iOS 9最新的UIAlertController