sorting - How to sort a LinkedHashMap by value in decreasing order in java stream? -


to sort int ascending order can use:

mymap.entryset().stream()     .sorted(map.entry.comparingbyvalue())     .collect(collectors.tomap(entry::getkey, entry::getvalue)); 

how can in decreasing order?

since java 1.8 java.util.comparator.reversed()

mymap.entryset().stream() .sorted(map.entry.comparingbyvalue().reversed()) .collect(collectors.tomap(entry::getkey, entry::getvalue)); 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -