Thanks a million. You just made my day.
Soren -----Oprindelig meddelelse----- Fra: Yan, Charlene [mailto:[EMAIL PROTECTED] Sendt: 10. marts 2003 23:12 Til: Struts Users Mailing List Emne: RE: Sort a collection in alphabetic order Try this: import org.apache.commons.beanutils.BeanComparator; Collections.sort(people, new BeanComparator("lastname")); Charlene -----Original Message----- From: Søren Blidorf [mailto:[EMAIL PROTECTED] Sent: Monday, March 10, 2003 4:33 PM To: 'Struts Users Mailing List' Subject: SV: Sort a collection in alphabetic order Sorry, but I can't get it to work. Does any body have a simple example I can look at? Soren -----Oprindelig meddelelse----- Fra: nash e. foster [mailto:[EMAIL PROTECTED] Sendt: 10. marts 2003 19:27 Til: Struts Users Mailing List Emne: Re: Sort a collection in alphabetic order You could have your PeopleBean implement Comparable, which is pretty easy, and then use TreeSet to create a sorted set using your compareTo method. -nash On Monday, March 10, 2003, at 01:16 PM, Søren Blidorf wrote: > > Hi. > I need to sort my collection "people" in alphabetic order by lastname, > firstname. > Can anybody help me? > > I guess I should do it in the Action and not when displayed in jsp > page. > > > > Collection people = new ArrayList(); > > while( rs.next() ) { > PeopleBean pb = new PeopleBean(); > pb.setId(rs.getInt("ID")); > pb.setFirstname( rs.getString( "FIRSTNAME" )); > pb.setLastname( rs.getString( "LASTNAME" )); > } > > people.add( pb ); > > > Søren Blidorf > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] *********************************************************************** This message is intended only for the use of the intended recipient and may contain information that is PRIVILEGED and/or CONFIDENTIAL. If you are not the intended recipient, you are hereby notified that any use, dissemination, disclosure or copying of this communication is strictly prohibited. If you have received this communication in error, please destroy all copies of this message and its attachments and notify us immediately. *********************************************************************** --------------------------------------------------------------------- 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] --------------------------------------------------------------------- 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]