0

I would like to show the highest values first, but its showing me the lower first:

songs.entrySet()
     .stream()
     .sorted(Comparator.comparing(Map.Entry::getValue))
     .forEach(songs -> System.out.println(songs.getKey() + " Rate:" + songs.getValue()));
Pshemo
  • 122,468
  • 25
  • 185
  • 269
J. Doe
  • 1
  • 1
    I think there's a `Comparator.reverse` that will reverse the sense of your test, and the order of the sorting. – markspace Apr 16 '18 at 17:25
  • How are you comparing them? I mean, if you don't give it anything, it'll use the default... – Dave Newton Apr 16 '18 at 17:25
  • 1
    Also note that there is `Map.Entry.comparingByValue()` (instead of `Comparator.comparing(Map.Entry::getValue)`). – lexicore Apr 16 '18 at 18:32

0 Answers0