How can I sort for example the 4th column of a JTable ?
The following code does not work:
TableRowSorter<TableModel> sorter = new TableRowSorter<>(jTable.getModel());
jTable.setRowSorter(sorter);
List<RowSorter.SortKey> sortKeys = new ArrayList<>();
int columnIndex = 4;
sortKeys.add(new RowSorter.SortKey(columnIndex, SortOrder.ASCENDING));
sorter.setSortKeys(sortKeys);
sorter.sort();
Jtable shows always the unsorted table.
I also tried with other columns. No sorting.