My problem is TableRowSorter is incorrectly sorting for double & integer, I've been searching and tried almost all solution listed below.
-using getColumnClass()
-using setComparator()
@Override
public Class<?> getColumnClass(int column)
{
if (column == 4)
return Integer.class;
else
return String.class;
}
};
sorter.setComparator(4, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
int len1 = o1.toString().length();
int len2 = o2.toString().length();
if (len1==len2) {
return o1.compareTo(o2);
} else {
return len1-len2;
}
}
})