<?xml version="1.0" encoding="UTF-8" ?>
<dt-example table-type="html-grade" order="2">

<css lib="datatables" />
<js lib="jquery" />
<js lib="datatables" />

<title>Ordering plug-ins (with type detection)</title>
<js><![CDATA[

$.fn.dataTable.ext.type.detect.unshift(
	function ( d ) {
		return d === 'Low' || d === 'Medium' || d === 'High' ?
			'salary-grade' :
			null;
	}
);

$.fn.dataTable.ext.type.order['salary-grade-pre'] = function ( d ) {
	switch ( d ) {
		case 'Low':    return 1;
		case 'Medium': return 2;
		case 'High':   return 3;
	}
	return 0;
};


$(document).ready(function() {
	$('#example').DataTable();
} );

]]></js>

<info><![CDATA[

Although DataTables will automatically order data from a number of different data types using the built in methods, when dealing with more complex formatted data, it can be desirable to define the ordering order yourself. Using plug-in ordering functions, you can have DataTables sort data in any manner you wish.

Formatted data of a particular kind can be automatically detected and a suitable ordering plug-in assigned to it by making use of DataTables' plug-in type detection abilities. For more information about ordering plug-ins, creating them and their requirements, please refer to the plug-in development documentation.

This example shows ordering with using an enumerated type.

A wide variety of ready made ordering plug-ins can be found on [the DataTables plug-ins page](//datatables.net/plug-ins/sorting).

]]></info>

</dt-example>
