Wednesday, February 20, 2008

BeanComparator

Sometimes you just have the requirement to sort java collections...In that case the BeanComparator from Jakarta Commons is quite handy:

ArrayList sortFields = new ArrayList();
sortFields.add(new BeanComparator("lastName"));
sortFields.add(new BeanComparator("firstName"));
ComparatorChain multiSort = new ComparatorChain(sortFields);
java.util.Collections.sort(rows,multiSort);

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home