-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathTest.java
More file actions
28 lines (19 loc) · 621 Bytes
/
Test.java
File metadata and controls
28 lines (19 loc) · 621 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.hmkcode;
import java.util.HashMap;
import java.util.Map;
public class Test {
public static void main(String[] args){
Map map = new HashMap();
//*value Class should implements the Comparable interface
//*String implements Comparable by default.
map.put("Z", "3");
map.put("D", "4");
map.put("A", "1");
map.put("B", "2");
map.put("F", "6");
map.put("E", "5");
System.out.println("Unsorted Map: "+map);
System.out.println("Sorted Map By Values: "+MapSort.sortByValue(map));
System.out.println("Sorted Map By Keys: "+MapSort.sortByKey(map));
}
}