Take a look at the TableView#getSortOrder :
public final ObservableList<TableColumn<S,?>> getSortOrder() Returns: An ObservableList containing zero or more TableColumn instances.
The sortOrder list determines the sort order of the TableColumn instances:
- An empty sortOrder list means that sorting is not applied to the TableView.
- If the sortOrder list contains only one column of the table, the TableView will be sorted using the sortType properties and the comparator of this TableColumn (if
TableColumn.sortable is true). - If the sortOrder list contains multiple instances of TableColumn, then the TableView is first sorted based on the properties of the first TableColumn. If two elements are considered equal, the second column table in the list is used to determine the order. This is repeated until the results of all TableColumn comparators are considered, if necessary.
You just need to put the first and last columns where previously setSortable(true) called both columns.
source share