I got a custom listview which contains info about tv shows, ie. show title, last episode, last episode date, next episode, next episode date an so on.
Now I want to sort the listview ie. by last episode date. The shows are stored in an Arraylist, and the date is stored as a string in the format MMM/dd/yyyy.
Sort by title works with follow code:
public void sortByTitle() {
Comparator<Show> comperator = new Comparator<Show>() {
@Override
public int compare(Show object1, Show object2) {
return object1.getTitle().compareToIgnoreCase(
object2.getTitle());
}
};
Collections.sort(dataFromDB, comperator);
lv1.setAdapter(new CustomListViewAdapter(this, dataFromDB));
}
Anyone who can help?
Same as you are sorting on the basis of title,can be done with dates also.
Example: