0
votes
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tblProduct.getModel());
tblProduct.setRowSorter(sorter);

List<RowSorter.SortKey> sortKeys = new ArrayList<>();
sortKeys.add(new RowSorter.SortKey(6, SortOrder.DESCENDING));
sorter.setSortKeys(sortKeys);

It is sorting it in order by the first number of the integer rather than the whole number, what is the easiest way of fixing this?

i.e. output like:

9
8
8
5
2
17
12
1
Suggests also that you have a 'wrong' model. The column contains a String and not Integerg00se
Unfortunately, I rarely work with JTables. I would guess you either need to change the model for the sort column to Integer like g00se intimated, or find a way to alter the comparator (if possible) to convert the String to an Integer for sorting purposes.WJS
The Oracle tutorial, How to Use Tables, will show you how to use JTables.Gilbert Le Blanc
You need to: 1) store Integer objects in the model and 2) override the getColumnClass(...) method of the model to tell the table what the class of each column of data contains. See: stackoverflow.com/questions/34026013/…camickr