DataTables table sorting example

Preamble

With DataTables you can alter the sorting characteristics of the table at initialisation time. Using the aaSorting initialisation parameter, you can get the table exactly how you want to present the information. The aaSorting parameter is an array of arrays where the first value is the column to sort on, and the second is 'asc' or 'desc' as required (it is a double array for multi-column sorting). The table below is sorted (descending) by the CSS grade. Note also that the 'Engine version' column is automatically detected as a numeric column and sorted accordingly.

Live example

Show entries
Search:
Rendering engineBrowserPlatform(s)Engine versionCSS grade
Trident Internet Explorer 4.0 Win 95+4X
TasmanInternet Explorer 4.5Mac OS 8-9-X
MiscDillo 0.8Embedded devices-X
MiscLinksText only-X
MiscLynxText only-X
Other browsersAll others--U
PrestoNintendo DS browserNintendo DS8.5C/A1
TridentInternet Explorer 5.0Win 95+5C
KHTMLKonqureror 3.1KDE 3.13.1C
TasmanInternet Explorer 5.1Mac OS 7.6-91C
Rendering engine Browser Platform(s) Engine version CSS grade
Showing 1 to 10 of 57 entries

Initialisation code

$(document).ready(function() {
	$('#example').dataTable( {
		"aaSorting": [[ 4, "desc" ]]
	} );
} );

Other examples

Basic initialisation

Advanced initialisation

API

Please refer to the DataTables documentation for full information about it's API properties and methods.