我用这code排序按字母顺序我的列表视图,但它不排序AZ排序它是ZA问题出在哪里?
adapter.sort(新比较<字符串>(){
@覆盖
公众诠释比较(ARG1字符串,字符串为arg0){
返回-arg1.compareTo(为arg0);
}
});
解决方案
也许字符 - 返回
和 arg1.compareTo(arg0中的'' );
i am using this code to sort my list view in alphabetic order but it doesn't sort it a-z it sorts it z-a where is The problem?
adapter.sort(new Comparator<String>() {
@Override
public int compare(String arg1, String arg0) {
return -arg1.compareTo(arg0);
}
});
解决方案
Maybe the character '-' between return
and arg1.compareTo(arg0);
?