Is there any Java open-source comparator for comparing beans by multiple fields for multi-column sorting? Each column can be sorted asceding or descending.
For singl
I recently wrote a Comparator to sort multiple fields within a delimited String record. It allows you to define the delimiter, record structure and sorting rules (some of which are type-specific).
Required information is seeded to the Comparator itself, either programmatically or through an XML file.
XML is validated by a package embedded XSD file. For example, below is a tab delimited record layout with four fields (two of which are sortable):
Column One
Column Two
Column Three
2
true
false
true
Column Four
1
true
true
true
yyyy-MM-dd
You would then use this in java like so:
Comparator comparator = new RowComparator(
new XMLStructureReader(new File("layout.xml")));
Library can be found here:
http://sourceforge.net/projects/multicolumnrowcomparator/