forked from hmkcode/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapSort.java
More file actions
19 lines (16 loc) · 423 Bytes
/
MapSort.java
File metadata and controls
19 lines (16 loc) · 423 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.hmkcode;
import java.util.Map;
import java.util.TreeMap;
public class MapSort {
//test
public static Map sortByValue(Map unsortedMap){
Map sortedMap = new TreeMap(new ValueComparator(unsortedMap));
sortedMap.putAll(unsortedMap);
return sortedMap;
}
public static Map sortByKey(Map unsortedMap){
Map sortedMap = new TreeMap();
sortedMap.putAll(unsortedMap);
return sortedMap;
}
}