ʹ�� Map��key�������� @param map @return
(Map<String, String> map, String sortMethod)
| 9 | * @return |
| 10 | */ |
| 11 | public static Map<String, String> sortMapByKey(Map<String, String> map, String sortMethod) { |
| 12 | if (map == null || map.isEmpty()) { |
| 13 | return null; |
| 14 | } |
| 15 | if (sortMethod.equals("ASCENDING")){ |
| 16 | Map<String, String> sortMap = new TreeMap<String, String>(new MapKeyComparator()); |
| 17 | sortMap.putAll(map); |
| 18 | return sortMap; |
| 19 | }else if (sortMethod.equals("DESCENDING")) { |
| 20 | Map<String, String> sortMap = new TreeMap<String, String>(new MapKeyComparatorDesc()); |
| 21 | sortMap.putAll(map); |
| 22 | return sortMap; |
| 23 | }else { |
| 24 | return null; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * ʹ�� Map��value�������� |
no outgoing calls
no test coverage detected