Object List Sorting Using BeanComparator

We can sort List<Objects> using BeanComparater instead of writing comparator. The beanutils.jar has to be imported. Default sort order is in ascending order.

For eg.
Collections.sort(postings, new BeanComparator(“resumeCount”));
BeanComparator bc = new BeanComparator(“resumeCount”);
Collections.sort(postings, bc);
Pros:- Concise, Minimal code
Cons:- Low performance, uses reflection (now if a field is renamed, the compiler won’t even report a problem)