public static <DealProgressBO> void listSort(List<DealProgressBO> list, String[] keys) {
try {
Comparator<DealProgressBO> comparator = new Comparator<DealProgressBO>() {
@Override
public int compare(DealProgressBO obj1, DealProgressBO obj2) {
// 定义中文语境
Collator instance = Collator.getInstance(Locale.CHINA);
return instance.compare(obj1, obj2);
}
};
comparator = ComparatorUtils.nullLowComparator(comparator);
//正序排序
//comparator = ComparatorUtils.reversedComparator(comparator);
// 创建一个排序链
ComparatorChain<Object> multiSort = new ComparatorChain<>();
for (String key : keys) {
multiSort.addComparator(new BeanComparator(key, comparator)); // 批量添加排序规则
}
// 开始真正的排序,按照先添加先排序的规则
Collections.sort(list, multiSort);
} catch (Exception e) {
}
}