A plugin for jQuery called “tableSorter” makes life so much easier when you wish to sort certain columns on a table, for example filtering a table to make total amount (£) ASC or DESC.

The only HTML markup requirement is to assign the table with an id or a class in this example I have created a table like this:

<table id="sortingTable">
</table

In this example I am assuming that you know how to populate a table correctly using thead tags etc.. So I will skip over this and get straight onto the jQuery sorting stuff.

The most stripped down and basic version can be called like this:

$(document).ready(function() {
     $('#sortingTable').tablesorter();
});

To get more out of table sorter we will need to use its config settings to define its behaviours.

In this example I will call a tablesorter disabling columns 1 and 2:

$(document).ready(function() {
     $('#sortingTable').tablesorter({
          headers: {
               0: {sorter: false},
               1: {sorter: false}
          }
     });
});

So there is an example of using table sorter with JQuery, for more information and for a full list of configuration settings and examples visit the tablesorter website