Created
January 28, 2017 17:58
-
-
Save leonardosnt/700b51bf0a4b420412bfa35268948aae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map<String, Integer> map = new HashMap<>(); | |
map.put("Foo", 233); | |
map.put("Bar", 76); | |
map.put("Quux", 762); | |
map.put("Fuux", 272); | |
map.entrySet() | |
.stream() | |
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())) | |
.forEach(e -> { | |
System.out.println(e.getKey() + " " + e.getValue()); | |
}); | |
/* | |
output: | |
Quux 762 | |
Fuux 272 | |
Foo 233 | |
Bar 76 | |
gg ez | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment