// 对集合对象进行排序(比较对象中的一个属性)
private static void doCompositor(List<CopLocationDto> copList){
Collections.sort (copList ,new Comparator<CopLocationDto>() {
@Override
public int compare(CopLocationDto o1, CopLocationDto o2) {
int s1 = o1!= null? o1.getSequence():0;
int s2 = o2!= null? o2.getSequence():0;
if ( s1 > s2 ){
return 1;
} else if( s1== s2){
return 0;
} else{
return -1;
}
}
});
}
/**
* 订单列表排序(根据时间排序)
* @param appOrders 订单列表
* @param sorttype 1:正序 0:倒序
*/
private static void sortOrderList(List<AppOrderEntity> appOrders, final int sorttype){
if ( appOrders== null|| appOrders.isEmpty()) {
return;
}
//组员数据排序,倒序
Collections.sort (appOrders , new Comparator<AppOrderEntity>() {
@Override
public int compare(AppOrderEntity o1, AppOrderEntity o2) {
Date s1 = o1 != null ? o1.getBanjia_time() : DateBuilder.getDate("yyyy-MM-dd HH:mm:ss", "0000-00-00 00:00:00");
Date s2 = o2 != null ? o2.getBanjia_time() : DateBuilder.getDate("yyyy-MM-dd HH:mm:ss", "0000-00-00 00:00:00");
if ( sorttype==1) {
return s1.compareTo( s2);
} else{
return s2.compareTo( s1);
}
}
});
}