[jdom-interest] Sorting a list of text elements
baltner at hq.nasa.gov
Fri Mar 16 04:42:20 PST 2001
I am trying to sort a list of text elements within my servlet, which uses
JDOM, for a pull down menu and am not getting it to work. Maybe I'm using
the sort method (part of the Java 2 Collections framework)
incorrectly. Here is the code snippet:
//get root and all first level children (as List)
Element root = doc.getRootElement();
Element menuItems = root.getChild("Categories");
List menuItem = menuItems.getChildren();
out.println(" <td><SELECT NAME=\"category\">");
Element elem = (Element)menuItem.get(i);
String menuItemText = elem.getTextTrim();
The Collections.sort(menuItem) line has no effect: the list is not sorted.
I am expecting alphabetical sorting as the "natural order." Can someone
point out what I need to do?
Thanks, in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the jdom-interest