peta java ke linkedhashmap dengan urutan kunci menaikkan

Map<String, Integer> unSortedMap = getUnSortedMap();

//LinkedHashMap preserve the ordering of elements in which they are inserted
LinkedHashMap<String, Integer> sortedMap = new LinkedHashMap<>();

unSortedMap.entrySet()
  .stream()
  .sorted(Map.Entry.comparingByKey())
  .forEachOrdered(x -> sortedMap.put(x.getKey(), x.getValue()));
Cookies4Techies