import java.util.*;
Collections.sort(list);
Collections.sort(list, Collections.reverseOrder());
list.sort(Comparator.naturalOrder());
list.sort(Comparator.reverseOrder());
Arrays.sort(arr);
Arrays.sort(arr, Collections.reverseOrder());
List<String> keys = new ArrayList<>(map.keySet());
Collections.sort(keys);
for (String key : keys) {
System.out.println(String.format("Key : %s, Value : %s", key, map.get(key)));
}
keys.sort(Collections.reverseOrder());
for (String key : keys) {
System.out.println(String.format("Key : %s, Value : %s", key, map.get(key)));
}