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
function columns().order( direction )
Order the table, in the direction specified, by the columns selected by the
Name Type Optional 1
Direction of sort to apply to the selected columns -
asc(ascending). Note this one direction is applied to all columns from the selector.
DataTables API instance
Sort by all columns with the class '.status':
var table = $('#example').DataTable(); table .columns( '.status' ) .order( 'desc' ) .draw();
The following options are directly related and may also be useful in your application development.