I have a Content node and I want to get the children sorted by a
particular node data type, such as a string called department, and I am
wondering the best way to do this.  I am envisioning an
java.util.Comparator class and a java.util.TreeSet that utilizes the
Comparator.  So you would do something like:

Collection children = root.getChildren(ItemType.CONTENT);
Comparator deptComp = new DeptComparator();
Set sortedChildren = new TreeSet(deptComp);
sortedChildren.addAll(children);

Then I could just iterate through that collection ordered by department.
The DeptComparator class would be one that I wrote that would look at
the "department" NodeData to determine how to order the children in the
TreeSet.  Is this the best way to do this or is there some way within
Magnolia that it would normally be done with?  I don't imagine at the
most extreme the number of items that will be sorted would exceed 1000.

Thanks,

Tom

----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------

Reply via email to