Note that there's also the java.util.LinkedHashMap which will maintain whichever order you insert the values in. This gives you the consistency of TreeMap without the overhead of resorting, if your data is already sorted when you're populating the Map. It also has a funky LRU-style option that orders the items based on which ones have been most recently accessed, but I've never used that.
I've found LinkedHashMap to be indispensible, and the performance is good according to the Javadoc. hth, Mike > -----Original Message----- > From: Jeff Beal [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 08, 2005 9:34 AM > To: Struts Users Mailing List; [EMAIL PROTECTED] > Subject: Re: Displaying a HashMap as a <select> > > > Even if the results coming out of the database are sorted, throwing > them into a non-sorted Collection, like a basic HashMap, will un-sort > them. If you use a List, you just preserve the database sort order. > If you use a TreeMap, you can get the same sort order, but the TreeMap > object will go through the work of sorting them all over again. > > > On Tue, 8 Mar 2005 09:17:49 -0500, David Johnson > <[EMAIL PROTECTED]> wrote: > > my thought was just to let the DB do the work on the > sorting. Is that bad? > > > > > > On Mon, 7 Mar 2005 21:29:08 -0700, Wendy Smoak > <[EMAIL PROTECTED]> wrote: > > > From: "James Mitchell" <[EMAIL PROTECTED]> > > > > I wouldn't use a Map, I would go with a List. > Primarily for ordering. > > > > > > I use java.util.TreeMap-- automatic alphabetical order > for my lists of > > > (String) codes and descriptions. > > > > > > -- > > > Wendy Smoak > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > -- > > -Dave > > [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > Jeff Beal > Webmedx, Inc. > Pittsburgh, PA USA > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]