I created a vector and I need to sort it by last name
is there any way somebody can help me to solve this problem
code is some what like this
Vector searchResult = new Vector();
for(int i=0; i<employeeIds.size();i++)
{
IUserFactory iUserFactory = UMFactory.getUserFactory();
try
{
logger.severe("user factory is :"+(String)employeeIds.get(i));
.
.
.
SearchResultBean searchResultBean = new SearchResultBean();
searchResultBean.setEmailAddress(iUser.getEmail());
.
.
searchResultBean.setLastName(iUser.getLastName());
searchResult.add(searchResultBean);
// I need to return the searchResult sorted by Last name
return searchResult;
}
Hi TT,
I would make a new class that extends SearchResultBean and implements Comparable to use Collections.sort(List).
Another question, i would use ArrayList instead Vector due to performace, if you don't need a synchronized list (Vector).
bye.
Add a comment