+ public void sortBy(int columnIndex, SortDirectionEnum sortDirection) {
+
+ if (columnIndex >= 0 && !sortDirection.equals(SortDirectionEnum.NONE)) {
+ Comparator<Integer> comparator = columnIndex == 0 ?
+ Comparator.comparing(k -> enabled[sortedRows[(int) k]]) :
+ Comparator.comparing(k -> records.get(sortedRows[(int) k]).get(columnIndex-1), VALUE_COMPARATOR);
+
+ if (sortDirection.equals(SortDirectionEnum.DESC))
+ comparator = comparator.reversed();
+
+ sortedRows = IntStream.range(0, records.size())
+ .mapToObj(i -> i)
+ .sorted(comparator)
+ .mapToInt(i -> sortedRows[i])
+ .toArray();
+ } else {
+ sortedRows = IntStream.range(0, records.size()).toArray();
+ }
+ }
+