MCPcopy Index your code
hub / github.com/bit4woo/ReSign / sortMapByValue

Method sortMapByValue

src/custom/CMapSort.java:33–51  ·  view source on GitHub ↗

ʹ�� Map��value�������� @param map @return

(Map<String, String> map, String sortMethod)

Source from the content-addressed store, hash-verified

31 * @return
32 */
33 public static Map<String, String> sortMapByValue(Map<String, String> map, String sortMethod) {
34 if (map == null || map.isEmpty()) {
35 return null;
36 }
37 Map<String, String> sortedMap = new LinkedHashMap<String, String>();
38 List<Map.Entry<String, String>> entryList = new ArrayList<Map.Entry<String, String>>(map.entrySet());
39 if (sortMethod.equals("ASCENDING")){
40 Collections.sort(entryList, new MapValueComparator());
41 }else if (sortMethod.equals("DESCENDING")) {
42 Collections.sort(entryList, new MapValueComparatorDesc());
43 }
44 Iterator<Map.Entry<String, String>> iter = entryList.iterator();
45 Map.Entry<String, String> tmpEntry = null;
46 while (iter.hasNext()) {
47 tmpEntry = iter.next();
48 sortedMap.put(tmpEntry.getKey(), tmpEntry.getValue());
49 }
50 return sortedMap;
51 }
52
53
54 public static String combineMapEntry(Map<String,String> map, Boolean onlyValue, String connector){

Callers 3

mainMethod · 0.95
combineStringMethod · 0.80
combineStringMethod · 0.80

Calls 2

getKeyMethod · 0.80
getValueMethod · 0.65

Tested by

no test coverage detected