I got htis method:
private <T, V extends Comparable<V>> boolean isColumnSorted(List<T> gridResult,
Function<T, V> extractor) {
List<T> sortedList = new ArrayList<>(gridResult);
sortedList.sort(Comparator.comparing(extractor));
return sortedList.equals(gridResult);
}
but i don't know to to change it if I would like to check if the list is sorted descending. Please help. Thanks.
使用Comparator
的reversed()
方法:
sortedList.sort(Comparator.comparing(extractor).reversed());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.