Since: DataTables 1.10

Order the table by the selected columns.


This method provides a useful alternative to the order() method, allowing you to select the columns that you want to be ordered using the flexible columns() selector and having them ordered in the direction specified.

Multi-column ordering is achieved by ensuring that the column selector matches multiple columns (single column ordering is performed if only one column is matched, or by using the column().order() method). The order of the matched columns defines the priority sequence in which the ordering of the table is applied.

Please be aware that this method sets the ordering to apply to the table - it does not actually perform the order. In order to have the order performed, use the draw() method, which can be called simply as a chained method of the order() method's returned object - for example table.order([0, 'desc']).draw();.


function columns().order( direction )


Order the table, in the direction specified, by the columns selected by the columns() selector.


DataTables API instance


Sort by all columns with the class '.status':

var table = $('#example').DataTable();

	.columns( '.status' )
	.order( 'desc' )


The following options are directly related and may also be useful in your application development.