@@ -0,0 +1,2135 @@
+//  Copyright 2016 The Minorminor Open Source Project%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A//     http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A//%0A%0Apackage utils;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Comparator;%0Aimport java.util.Map;%0Aimport java.util.TreeMap;%0A%0Apublic class MapUtils %7B%0A    public static %3CK extends Comparable%3C? super K%3E, V extends Comparable%3C? super V%3E%3E%0A    Map sortByValueInDescendingOrder(final Map%3CK, V%3E map) %7B%0A        Map re = new TreeMap(new Comparator%3CK%3E() %7B%0A            @Override%0A            public int compare(K o1, K o2) %7B%0A                if (map.get(o1) == null %7C%7C map.get(o2) == null) %7B%0A                    return -o1.compareTo(o2);%0A                %7D%0A                int result = -map.get(o1).compareTo(map.get(o2));%0A                if (result != 0) %7B%0A                    return result;%0A                %7D%0A                return o1.compareTo(o2);%0A            %7D%0A        %7D%0A        );%0A        re.putAll(map);%0A        return re;%0A    %7D%0A%0A    public static %3CK extends Comparable%3C? super K%3E, V extends Comparable%3C? super V%3E%3E%0A    Map.Entry%3CK, V%3E%5B%5D sortedArrayByValueInDescendingOrder(final Map%3CK, V%3E map) %7B%0A%0A        Map.Entry%3CK, V%3E%5B%5D result = new Map.Entry%5Bmap.size()%5D;%0A        map.entrySet().toArray(result);%0A%0A        Arrays.sort(result, new Comparator%3CMap.Entry%3CK, V%3E%3E() %7B%0A            @Override%0A            public int compare(Map.Entry%3CK, V%3E o1, Map.Entry%3CK, V%3E o2) %7B%0A                int result = -o1.getValue().compareTo(o2.getValue());%0A                if (result != 0) %7B%0A                    return result;%0A                %7D%0A                return o1.getKey().compareTo(o2.getKey());%0A            %7D%0A        %7D);%0A        return result;%0A    %7D%0A%7D%0A

Add MapUtils class