I\'m working on a android chatting application. When I called my api it returns me the chat list sorted by a user_id. But what I need to do is serialized by
try this before passing your list to the adapter (after API call and before adapter notifydatasetchanged):
Collections.sort(data, new Comparator() {
@Override
public int compare(CustomData lhs, CustomData rhs) {
// -1 - less than, 1 - greater than, 0 - equal, all inversed for descending
return lhs.getId() > rhs.getId() ? -1 : (lhs.customInt < rhs.customInt ) ? 1 : 0;
}
});