I have an ArrayList of custom objects that I want to sort alphabetically. The problem is that the field I want to sort it by sometimes contains non-english characters, like á
or é
.
I wanted to do this by using Collections.sort()
, but with this method, the items with non-english strings in their fields don't get sorted correctly.
This is what I've tried:
public List<Video> sortDatabase(List<Video> videos){
List<Video> sortedList = new ArrayList<>(videos);
Collections.sort(sortedList, new Comparator<Video>() {
@Override
public int compare(Video video, Video t1) {
return video.getTitle().compareTo(t1.getTitle());
}
});
return orderedList;
}
EDIT
I am using Android Studio with minSdkVersion 21