[jdom-interest] why can't I sort this list?

Alex Rosen arosen at silverstream.com
Wed Jul 24 10:17:48 PDT 2002


I couldn't think of a good way to make Collections.sort() work with our
lists. Instead, I wrote a different sort method that would work:

http://www.servlets.com/archive/servlet/ReadMsg?msgId=211785&listName=jdom-i
nterest

Or, you can do:

// Make a new list, with the same contents, that's not live
// (i.e. not attached to the parent Element).
List temp = new ArrayList(listOfChildren);
Collections.sort(temp);
// Set the contents of the parent to the new, ordered list.
parentElement.setContent(temp);

Alex




More information about the jdom-interest mailing list