[Solved] How to have jtables values which are strings in alphabetical order using comparator and tablerowsorter? [closed]


You must create a comparator:

Comparator<String> comparator = new Comparator<String>() {
    public int compare(String s1, String s2) {
         return s1.compareTo(s2);
    }
};

With this comparator you will be able to sort your data in alphabetical order.

After that create sorter and pass this comparator and model of your JTable.

Then:

sorter.sort();

I think after that your data will be sorted.

4

solved How to have jtables values which are strings in alphabetical order using comparator and tablerowsorter? [closed]