src/main/java/me/codeboy/common/base/util/CBMapSortUtil.java
private Map<K, V> sortByKey(Map<K, V> sourceMap, final int growthPattern) {
        List<Entry<K, V>> list = new ArrayList<Entry<K, V>>(
                sourceMap.entrySet());
        Collections.sort(list, new Comparator<Entry<K, V>>() {

            @Override
            public int compare(Entry<K, V> o1, Entry<K, V> o2) {
                K k1 = o1.getKey();
                K k2 = o2.getKey();
                return compareValue(k1, k2) * growthPattern;
            }
        });

        Map<K, V> desMap = new LinkedHashMap<K, V>();
        for (int i = 0; i < list.size(); i++) {
            Entry<K, V> item = list.get(i);
            desMap.put(item.getKey(), item.getValue());
        }
        return desMap;
    }
private Map<K, V> sortByKey(Map<K, V> sourceMap, final int growthPattern) {
        List<Entry<K, V>> list = new ArrayList<Entry<K, V>>(
                sourceMap.entrySet());
        Collections.sort(list, new Comparator<Entry<K, V>>() {

            @Override
            public int compare(Entry<K, V> o1, Entry<K, V> o2) {
                K k1 = o1.getKey();
                K k2 = o2.getKey();
                return compareValue(k1, k2) * growthPattern;
            }
        });

        Map<K, V> desMap = new LinkedHashMap<K, V>();
        for (int i = 0; i < list.size(); i++) {
            Entry<K, V> item = list.get(i);
            desMap.put(item.getKey(), item.getValue());
        }
        return desMap;
    }
根据map中key进行排序

@param sourceMap
要排序 map
@param growthPattern
排序规则，升序或者降序
@return 排序后 map