i have a list with description of users like this:
0_Mary_Rose_maryrose@gmail.com
1_John_Smith_johnsmith@gmail.com
How can I order the list alphabetically?
I have this method:
protected List<String> ShowUsers() { // show users list
List<String> allUsersDesc = new ArrayList<>(); // creates list for users description
for (Map.Entry<Integer, User> user : _userMap.entrySet()) { // scrolls users list
allUsersDesc.add(user.getValue().getUserDescription()); // adds registered users
}
Collections.sort(allUsersDesc); // sorts by description
return allUsersDesc; // return description list }
and getUserDescription
:
public String getUserDescription(){
String description = "" + getUserId() + "-" + getName() + "-" + getEmail() + "-" + getBehavior() + "-" + isActive();
return description;
}
But like this it is ordering by description and the first item of description is a number, so it is ordering by number and not by the users name.