Sorting an ArrayList in Android
in this method for sorting names or contact list in alphabetical orderArrayList<User> res = new ArrayList<User>();
res.add(…);res.add(…);
Comparator<User> comperator = new Comparator<User>() {
@Override
public int compare(User object1, User object2) {
return object1.name.compareToIgnoreCase(object2.name);
}
};
Collections.sort(res, comperator);
Sorting an Array in Android
User[] res = new User[];
res.add(…);res.add(…);
Comparator<User> comperator = new Comparator<User>() {
@Override
public int compare(User object1, User object2) {
return object1.name.compareToIgnoreCase(object2.name);
}
};
Array.sort(res, comperator);
Most essential drugs are offered free of charge in these hospitals. However, the fact that the government sector is understaffed,
ReplyDelete