android 排序

2018-09-20  本文已影响0人  文强小弟

List<Customer> customerData;
Collections.sort(customerData,new Customer());
public class Customer implements Comparator<Customer>{
private String cusName;
public String getCusName() {
return cusName;
}
public void setCusName(String cusName) {
this.cusName = cusName;
}
// 不区分大小写排序使用
@Override
public int compare(Customer customer1,Customer customer2) {
String cusName1 = customer1.getCusName().toString().toUpperCase();
String cusName2 = customer2.getCusName().toString().toUpperCase();
return cusName1.compareTo(cusName2);
}
}

上一篇下一篇

猜你喜欢

热点阅读