How to sort a map with the key first and sort the values as well.
Map<String, List<String>> myMap = new HashMap<>();
myMap.put("Apple", Arrays.asList("iphone", "imac"));
myMap.put("Samsung", Arrays.asList("galaxys", "galaxyz"));
myMap.put("LG", Arrays.asList("ultra", "tab"));
//sort logic
Sort with the key first {Apple, LG, Samsung} and then sort the values based on the key.
Result:
imac, iphone, tab, ultra, galaxys, galaxyz