suppose we have array list of User
User class have following params
param :
uid
name
address
suppose ArrayList<User> users has many values and we want it to sory by name then use following code.
Collections.sort(users, new Comparator<User>() {
@Override
public int compare(User u1, User u2) {
return u1.name.compareToIgnoreCase(u2.name);
}
});
above code will sort users array by name.
No comments :
Post a Comment