public Sort getSort(Pager pager) {
Sort sort = null;
try {
ArrayList orders;
int i;
Sort.Order order;
if (pager.getExtString().equals("DESC")) {
if (pager.getSortFields().length == 1) {
sort = Sort.by(new Sort.Order[]{new Sort.Order(Sort.Direction.DESC, pager.getSortFields()[0])});
} else {
orders = new ArrayList();
for (i = 0; i < pager.getSortFields().length; ++i) {
order = new Sort.Order(Sort.Direction.DESC, pager.getSortFields()[i]);
orders.add(order);
}
sort = Sort.by(orders);
}
}
if (pager.getExtString().equals("ASC")) {
if (pager.getSortFields().length == 1) {
sort = Sort.by(new Sort.Order[]{new Sort.Order(Sort.Direction.ASC, pager.getSortFields()[0])});
} else {
orders = new ArrayList();
for (i = 0; i < pager.getSortFields().length; ++i) {
order = new Sort.Order(Sort.Direction.ASC, pager.getSortFields()[i]);
orders.add(order);
}
sort = Sort.by(orders);
}
}
return sort;
} catch (Exception var6) {
this.logger.error(var6.toString());
return new Sort(new Sort.Order[]{new Sort.Order(Sort.Direction.ASC, pager.getSortFields()[0])});
}
}
来源:CSDN
作者:yilushunfengli
链接:https://blog.csdn.net/yilushunfengli/article/details/104048087