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);
}
}
网友评论