In my use case the secondary sorting option is more of a hinderance. The solution I came up with only allows sorting a column in one way, clicking the header toggles between sorted and not used for sorting.
Only allowing descending sorting is simpler and only requires a listener to the table sortOrder. Only allowing ascending sorting however requires adding a listener to the column sortTypeProperty and for multisorting using the shift-key to work correctly the correct sorting must also be forced in the table sortOrder listener.
columnLosses.sortTypeProperty().addListener(o -> {
if (columnLosses.getSortType().equals(TableColumn.SortType.DESCENDING)) {
table.getSortOrder().remove(columnLosses);
}
});
table.getSortOrder().addListener((Observable o) -> {
if (table.getSortOrder().contains(columnWins)) {
columnWins.setSortType(TableColumn.SortType.DESCENDING);
}
if (columnLosses.getSortType().equals(TableColumn.SortType.DESCENDING)) {
columnLosses.setSortType(TableColumn.SortType.ASCENDING); // needed for correct multicolumn sorting
}
});