Quantcast
Channel: How to sort List of objects by some property - Stack Overflow
Viewing all articles
Browse latest Browse all 19

Answer by Dimitar Milanov for How to sort List of objects by some property

$
0
0

Here's what did the trick for me.Was much shorter and easier than everything else I found:

Collections.sort(listName, Comparator.comparing(Object::getProperty).reversed());

The ".reversed()" part at the end was a requirement for my specific project but I'm sharing it too, as it took a while to find it


Viewing all articles
Browse latest Browse all 19

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>