Skip to Content
author's profile photo Former Member
Former Member

Table Column Sorting


New year to all.

I would just like to give a gentle reminder on the 'Table Column Sorting' i had posted.

It would be great if you can provide me some sample code highlighting the use of



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2004 at 02:38 PM

    Hi Vishal,

    And here the answer as well within this posting! Happy New Year to you as well!

    Best Regards,


    The sort method asks everytime the comparator, if the method has to compare two lines, which one is "smaller" than the other one. In other words: within the code of the comparator is defined, which column has to be compared.

    An example: Assuming, we have a node "Customers", which I want to sort by attribute "name". The comparator would look like this:

    // create an anonoymous implementation of the interface Comparator

    Comparator comparator = new Comparator() {

    // this method compares two instances of the list (in our case

    // CustomersElements)

    int compare(Object a, Object b) {

    // the method gets Objects, but we know that they're

    // CustomersElements

    CustomersElement ea = (CustomersElement)a;

    CustomersElement eb = (CustomersElement)b;

    // compare the names (String.compareTo does exactly what we need)

    return ea.getName().compareTo(eb.getName());



    // sort using this comparator


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.