//根据List集合中某个对象中的元素对集合进行排序
//根据List集合中某个对象中的元素对集合进行排序
//排序字段为String时
java.util.Collections.sort(list,new Comparator<Bean>() {
@Override
public int compare(Bean arg0, Bean arg1) {
return arg0.getBillNo().compareTo(arg1.getBillNo());
}
});
//排序字段为int时
java.util.Collections.sort(glManifestIHeadList,new Comparator<GlManifestIHead>() {
@Override
public int compare(GlManifestIHead arg0, GlManifestIHead arg1) {
if(arg0.getBillNo()>arg1.getBillNo()){
return 1;
}
if(arg0.getBillNo()<arg1.getBillNo()){
return -1;
}
return 0;
};
//排序单纯String
String mealTypeId = req.getParameter("mealTypeId");//餐别 "0,3,5,1,2,4"
String [] meals = mealTypeId.split(",");
List<String> list = Arrays.asList(meals);
Collections.sort(list, String::compareTo);
mealTypeId = String.join(",", list);//"0,1,2,3,4,5"
、、
}