You can use a comparator or you can implement the compareable interface to you class. I give you an example for the secound way:
Collections.sort(UserSessionList);
The class UserSession must implements Comparable<UserSession>
now. And then you can override the compareTo method of this class. For example:
@Override
public int compareTo(UserSession o) {
if(null== o)
return 1;
if(getWorkStationName() == null && o.getWorkStationName()==null)
return 0;
if(getWorkStationName() == null && o.getWorkStationName()!=null)
return -1;
if(getWorkStationName() != null && o.getWorkStationName()==null)
return 1;
return o.getWorkStationName().compareTo(getWorkStationName());
}
The rest of the compare function you have to write by your own now! :)