I came across this useful Util class provided by Apache Commons Collections.
ComparatorUtils
one of the useful methods here is chainedComparator which allows us to chain comparators to achieve sorting on multiple attributes of an object.
if the results from the first comparator result in 0 then the next comparator is invoked.
I remember writing a Util for myself for the same. But This class is much more robust and accessible.
No comments:
Post a Comment