I noticed on the dev-list that Alexander Popescu had put in a new
Content.getChildren() method that would take a comparator and along with
a ContentFilter.  Similar to what I was asking about yesterday.  I'm
assuming that is the indirect way of confirming the direction I'm going
is correct.

Thanks,

Tom

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 23, 2006 12:54 PM
To: [email protected]
Subject: [magnolia-user] sorting children

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
----------------------------------------------------------------

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

Reply via email to