@Override
public int compareTo(final myRow another) {
final int BEFORE =-1;
final int EQUAL = 0;
final int AFTER = 1;
if (this==another) return EQUAL;
if (sorttype==sort_type.SORT_ABC) {
int rv =0;
int sorted =row.toLowerCase().compareTo(another.getRow().toLowerCase());
if (this.getUserType()==user_type.USER_TYPE_BANNED) rv=AFTER;
if (this.getUserType()==user_type.USER_TYPE_NORMAL) rv=sorted;
if (this.getUserType()==user_type.USER_TYPE_FRIEND) rv=BEFORE;
Log.e("sorted", row+" "+this.getUserType()+" - "+rv+" ");
return rv;
} else if (sorttype==sort_type.SORT_LOGINTIME) {
if (this.getUserType()==user_type.USER_TYPE_BANNED) {
return AFTER;
}
if (this.getUserType()==user_type.USER_TYPE_NORMAL) return EQUAL;
if (this.getUserType()==user_type.USER_TYPE_FRIEND) {
//int sorted =row.toLowerCase().compareTo(another.getRow().toLowerCase());
return BEFORE;
}
//return 0;
}
return 0;
//return row.toLowerCase().compareTo(another.getRow().toLowerCase());
}
I have a String userlist, with nick names. I have banned users, normal users, and friend users.
I d like to sort my friend users to the top of the list, and the banned users to the bottom of the list, and I d like to showing them is ASC style.
How can i do that?
So the structure is:
Abc (friend)
abrt (friend)
dfgh (friend)
abdfg (normal user)
bnmm (normal user)
wert (normal user)
Andgh (banned user)
Dfghhj (banned user)
Qwer (banned user)
I get this:
06-19 14:43:46.586: ERROR/AndroidRuntime(23434): java.lang.IllegalArgumentException: Comparison method violates its general contract!