You must add the below code to your actual code that doesn't sort your column as Integer.
Your actual code to build your JTable is:
DefaultTableModel modeloT = new DefaultTableModel();
// But Sorts the column of numbers in wrong way. 1,11,2,25,......
SOLUTION:
DefaultTableModel modeloT = new DefaultTableModel() {
// Defining the type of column on your JTable. I wish sort my second column as a numeric (1,2,11), not String (1,11,2). For that I defined the second class as Integer.
Class[] types = { String.class, Integer.class, String.class };
boolean[] canEdit = new boolean [] {
false, false, false
};
// You must add this Override in order to works sorting by numeric.
@Override
public Class getColumnClass(int columnIndex) {
return this.types[columnIndex];
}
// This override is just for avoid editing the content of my JTable.
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};