Quantcast
Viewing latest article 7
Browse Latest Browse All 19

Answer by Karthikeyan for How to sort List of objects by some property

In java8+ this can be written in single line as follows:

collectionObjec.sort(comparator_lamda) or comparator.comparing(CollectionType::getterOfProperty)

code:

ListOfActiveAlarmObj.sort((a,b->a.getTimeStarted().compareTo(b.getTimeStarted())))

or

ListOfActiveAlarmObj.sort(Comparator.comparing(ActiveAlarm::getTimeStarted))

Viewing latest article 7
Browse Latest Browse All 19

Trending Articles



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