list 中排序分为降序和升序
class="java" name="code">
private List<LookupEntry> lookupEntryDescSort(List<LookupEntry> list) {
// TODO Auto-generated method stub
Collections.sort(list,new Comparator<LookupEntry>() {
@Override
public int compare(LookupEntry o1, LookupEntry o2) {
// TODO Auto-generated method stub
//降序
return o2.getName().compareTo(o1.getName());
}
});
return list;
}
private List<LookupEntry> lookupEntryAscSort(List<LookupEntry> list) {
// TODO Auto-generated method stub
Collections.sort(list,new Comparator<LookupEntry>() {
@Override
public int compare(LookupEntry o1, LookupEntry o2) {
// TODO Auto-generated method stub
//升序
return o1.getName().compareTo(o2.getName());
}
});
return list;
}