Getting a java collection of objects in Alphabetical order

Posted by MichaelMcCabe on Stack Overflow See other posts from Stack Overflow or by MichaelMcCabe
Published on 2010-05-13T14:00:36Z Indexed on 2010/05/13 14:04 UTC
Read the original article Hit count: 153

Filed under:
|
|
|
|

I have a question that I dont really know where to start. So I thought i'd ask it here.

Basically, I have a drop down with names in it. I want these names to be in alphabetical order.

Populating the drop down happens as follows;

I query a database and pull down an Id and Name, make a object called "UserList", and set the name and id variables with what I get back. I then add this object to an ArrayList. I do this over and over.

I then convert this collection to an array, and pass it to my JSP page using

session.setAttribute("userList", UserList);

I then populate the drop down as below.

<c:forEach items="${usersCompanysList}" var="c" >

There probably is a simple answer but how to I sort these names?

© Stack Overflow or respective owner

Related posts about java

Related posts about jsp