Refering to this question
Sadly I cannot comment because of low reputation but I have a question relating to this solution. I want to sort ascending AND descending (on click), but keep an empty string (represents the second sort parameter) always on top of something written..
I want it like:
My code works only for ASCENDING, on descending the string is before the empty one..
SECOND_SORT {
public int compare(String s1, String s2) {
if (s1.equals("") && s2.equals("")) {
return 0;
}
if (s1.equals("")) {
return -1;
}
if (s2.equals("")) {
return 1;
}
return s1.compareTo(s2);
}
This is the sort..
if (mSortingIdentifier == SortingIdentifier.DESC) {
Collections.sort(list, Comparator.descending(Comparator.getComparator(Comparator.FIRST_SORT, Comparator.SECOND_SORT)));
} else {
Collections.sort(list, Comparator.ascending(Comparator.getComparator(Comparator.FIRST_SORT, Comparator.SECOND_SORT)));
}