1Map<String, String> newMapSortedByKey = sample.entrySet().stream()
2 .sorted((e1,e2) -> e1.getKey().compareTo(e2.getKey()))
3 .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1,e2) -> e1, LinkedHashMap::new));
4