List排序
public void sortCodeList(List<KeCode> keCodeList) {
try {
if(keCodeList==null) {
return;
}
if(StringUtils.isBlank(orderby)) {
return;
}
if(StringUtils.equals(orderby, "asc")) {
Collections.sort(keCodeList, new Comparator<KeCode>() {
@Override
public int compare(KeCode o1, KeCode o2) {
return o1.getCodeEName().compareTo(o2.getCodeEName());
}
});
}else if(StringUtils.equals(orderby, "desc")) {
Collections.sort(keCodeList, new Comparator<KeCode>() {
@Override
public int compare(KeCode o1, KeCode o2) {
return o2.getCodeEName().compareTo(o1.getCodeEName());
}
});
}
} catch (Exception e) {
e.printStackTrace();
}
}