I came across this answer while trying to sort my hash map and collect it to a List:
Sort a Map<Key, Value> by values
I tried this:
return myMap.entrySet().stream()
.sorted(Map.Entry.comparingByValue())
.collect(Collectors.toList(Map.Entry::getKey, Map.Entry::getValue, (k,v) -> k, LinkedList::new));
However, I get this error:
Cannot resolve constructor 'LinkedList'
All I want to do is collect my keys into a list after sorting my HashMap by values. What am I doing wrong?