title: Java常用代码块 date: 2016-11-08 tags: Java comments: false cover: https://static.jqwei.com/blog/img/IMG_3461.PNG
/**
* map 按 key 升序排序
*
* @param map
* @return
*/
private static Map<String, Object> sortByKey(Map<String, Object> map) {
Map<String, Object> result = new LinkedHashMap<>(map.size());
map.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.forEachOrdered(e -> result.put(e.getKey(), e.getValue()));
return result;
}