java中对集合排序,可使用Collections.sort来进行排序,能够对中文、字母、数字进行排序

java中对集合排序,可使用Collections.sort来进行排序,能够对中文、字母、数字进行排序,当比较的是对象时候,让该类实现comparable接口,示例以下
Collections.sort(findShangpID, new Comparator<PageData>() {
@Override
public int compare(PageData o1, PageData o2) {
Double o1n=o1.getDouble("stock1")+o1.getDouble("stock2")+o1.getDouble("stock3");
Double o2n=o2.getDouble("stock1")+o2.getDouble("stock2")+o2.getDouble("stock3");
if(o1n>o2n){
return -1;
}else if(o1n==o2n){
return 0;
}else if(o1n<o2n){
return 1;
}
return 0;
}
});