We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent faafc82 commit e678d64Copy full SHA for e678d64
MapSort/src/com/hmkcode/Test.java
@@ -0,0 +1,28 @@
1
+package com.hmkcode;
2
+
3
4
+import java.util.HashMap;
5
+import java.util.Map;
6
7
+public class Test {
8
+public static void main(String[] args){
9
10
11
+ Map map = new HashMap();
12
13
+ //*value Class should implements the Comparable interface
14
+ //*String implements Comparable by default.
15
16
+ map.put("Z", "3");
17
+ map.put("D", "4");
18
+ map.put("A", "1");
19
+ map.put("B", "2");
20
+ map.put("F", "6");
21
+ map.put("E", "5");
22
23
+ System.out.println("Unsorted Map: "+map);
24
+ System.out.println("Sorted Map By Values: "+MapSort.sortByValue(map));
25
+ System.out.println("Sorted Map By Keys: "+MapSort.sortByKey(map));
26
27
+ }
28
+}
0 commit comments