#: Christoph Bütler changed the world a bit at a time by saying on 9/22/2005
1:01 AM :#
Hi Magnolians
I've a script which reads some NodeDatas of childPages into a
fatherPage. Now I try to sort these by a specified NodeData.
Here's the code:
//
//Array for the sorted children
ArrayList childrenArrayList = new ArrayList();
//
//Iterate through children an get the nodeData
for (Iterator myChildrenIterator = myChildren.iterator();
myChildrenIterator.hasNext();) {
//
//go throug the paragraph
Content para = (Content)myChildrenIterator.next();
//
//Get the nodeData
Iterator paraNodes = para.getChildren().iterator();
Content nodes = (Content)paraNodes.next();
String node4sort = nodes.getNodeData("region").getString();
//Fill the ArrayList
childrenArrayList.add(node4sort);
}
childrenArrayList.add("cc"); -->Just for testing
childrenArrayList.add("aa"); -->Just for testing
childrenArrayList.add("bb"); -->Just for testing
//
//now sort the array
int size = childrenArrayList.size();
Collections.sort(childrenArrayList);
for (int i=0; i<size; i++) {
out.println(childrenArrayList.get(i) + "<br />");
}
Now I get an unsorted list of "node4sort", but the strings "cc", "aa",
"bb", which I add for testing, are sorted.
Sorry. This is a bit OT, but can anybody give me a hint. String is
string? or not
Thanks
Christoph
I am not sure I have followed it: are you saying that Collections.sort is not correctly sorting the
list? Are you sure the string retrieved from nodes is trimmed?
./alex
--
.the_mindstorm.
----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------
----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------