Introduction

tablesorter is a jQuery PlugIn for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell.

First Name Last Name Age Total Discount Difference Date
PeterParker28$9.9920.9%+12.1Jul 6, 2006 8:14 AM
JohnHood33$19.9925%+12Dec 10, 2002 5:14 AM
ClarkKent18$15.8944%-26Jan 12, 2003 11:14 AM
JamesBond46$153.1944.7%+77Jan 18, 2001 9:12 AM
BruceEvans22$13.1911%-100.9Jan 18, 2007 9:12 AM
BrianEvans22$13.1911%0Jan 18, 2007 9:12 AM
PeterParker28$9.9920.9%+12.1Jul 6, 2006 8:14 AM
JohnHood33$19.9925%+12Dec 10, 2002 5:14 AM
ClarkKent18$15.8944%-26Jan 12, 2003 11:14 AM
JamesBond45$153.1944.7%+77Jan 18, 2001 9:12 AM
BruceEvans22$13.1911%-100.9Jan 18, 2007 9:12 AM
BruceSmith65$13.1911%0Jan 18, 2007 9:12 AM
AlbertEinstein45$5.01562564.1%-20Dec 18, 2001 9:12 AM
AlbertEinstein30$6.01562564.1%-25Feb 29, 2000 9:15 AM

TIP! Sort multiple columns simultaneously by holding down the shift key and clicking a second, third or even fourth column header!

Simple Load of tablesorter on the named table id:

$(document).ready( function()
	{
		$("#myTable").tablesorter();
	}
);

Initial Sort Load of tablesorter

Syntax: [column,sortdirection],[column = 0 ... n, direction = ascend 0|descend 1], [2,0], [3,0], [4,1], [5,1]
This tells tablesorter to sort on the first [0, 0|1] and second column [1] in ascending [0] order.

$(document).ready(function()
	{
		$("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} );
	}
);	
    
    
/* Actual */
$( function() {
    $("#tablesorter-demo").tablesorter({
        sortList: [[0, 0], [2, 1]],     /* column 0 ascending 0 and column 2 descending 1 */
        widgets: ['zebra']              /* dunno */
    });
});
/* Actual */

Click on the headers and you'll see that your table is now sortable!
You can also pass in configuration options when you initialize the table.