Sorting HashMap by values in ascending and descending order

The below example shows Java program to sort a Map by values in ascending and descending order, you can see that it’s so easy to sort the Map.