Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

hashmap sort ascending

LinkedHashMap<String, Integer> sortedMap = new LinkedHashMap<>();
 
unSortedMap.entrySet()
    .stream()
    .sorted(Map.Entry.comparingByKey())
    .forEachOrdered(x -> sortedMap.put(x.getKey(), x.getValue()));
 
PREVIOUS NEXT
Tagged: #hashmap #sort #ascending
ADD COMMENT
Topic
Name
7+9 =