Ok, well I have a JTable with several different types of text in each column and I would like to know how to specify how to sort each column. Some of the text is just text, some are numbers, and some are formatted numbers. At the moment, it is obviously treating each column as Strings, so it is just sorting based on the text-equivalent of each cell of data.
So, here is the outline of the cells, 2 examples of their data, and how I want to sort them (column numbers are in indexes):
Column 2:
Type: Double, only positive numbers
Example 1: 150
Example 2: 1,000.25
Sort Goal: Numerically
Column 3:
Type: String containing a double and an int, only positive numbers
Example 1: 1,098/1,098
Example 2: 29.15/150
Sort Goal: Numerically by the number after the slash
Column 4:
Type: String, representing a percentage, only positive percentage
Example 1: 100%
Example 2: 15%
Sort Goal: Numerically
Column 5:
Type: Double, can be negative or positive
Example 1: 27,110.13
Example 2: -289.74
Sort Goal: Numerically
Here is my code of giving the ability to sort:
RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); table.setRowSorter(sorter);
I've been trying to do several things, but I just don't understand enough about how the TableRowSorter works in order for me to break some ground here. Can anyone give me some guidance as to how to specify how I want the rows to be sorted?