import java.util.*;
public class demo15 {
public static void main(String[] args) {
HashMap<Integer, Integer> map = new HashMap<>();
map.put(4,5);
map.put(7,8);
map.put(3,4);
map.put(2,6);
List<Map.Entry<Integer,Integer>> list = new ArrayList<>(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<Integer, Integer>>() {
@Override
public int compare(Map.Entry<Integer, Integer> t0, Map.Entry<Integer, Integer> t1) {
return t0.getValue()-t1.getValue();
}
});
for (Map.Entry<Integer,Integer> entry:
list) {
System.out.println(entry.getKey()+" "+entry.getValue());
}
}
}