I have a JTable with a custom TableModel that extends AbstractTableModel. I have also used the built in table sorting by calling:
table.setAutoCreateRowSorter(true);
The model also return the right class of the data for each column from the getColumnClass() call, which from what I read should ensure the fastest sorting being done.
While it works fine and is indeed a very quick way to get sorting in your JTables its exceptionally slow when the number of rows reaches 5000+ entries. My table of almost 10000 rows now take 6-7 seconds to sort on a fairly powerful computer. But if I sort the data myself before adding them to the model using collections sort algorithm it is done in a few milliseconds!
I am suspecting the built in sorter is firing a lot of unecessary events for each "swap" of items going on in the sorter algorithm even though repainting is halted until its finished (the built in sorter is obviously run in the AWT thread and hence locks up the whole GUI/repainting). I have not analyzed this by looking at what is actually going on in the table sorting though.
I am tempted to drop the whole built-in sorter and just detect the column header clicks and just sort the model myself before doing a fireTableDataChanged() which is what the built in sorter should have done.
But before I do that, am I overlooking something that could make the built in sorter quick?