DataTables provides two APIs for sorting information in a table:
- Type based sorting
- Custom data source sorting
By far the most commonly used of these two types is "type based sorting" and is the one you are most likely to want to use if just starting out with DataTables.
The main DataTables package includes sorting functions for strings, dates, numeric and currency data, but you may very well wish to order data in some other manner, for example date formats not built in. The sorting functions below provide a wealth of different sorting methods that can be used with DataTables.
It is also worth noting that sorting function go hand-in-hand with type detection plug-ins, and many of the sorting plug-ins below has a corresponding type detection function to make installation very easy.
columns.type parameter for the column you want to have this sorting type applied to, set it to the value needed for the plug-in (this isn't needed if you use a type detection plug-ins for the sorting type.
|time-elapsed-dhms||Created by caochenghua on 2016/12/22.|
|nepali-numbers||Sorts columns containing UTF8 nepali numbers|
|czech-string||Sort locale aware sorting for Czech.|
|chapter||Sort book chapters numerically|
|natural||Sort data with a mix of numbers and letters _naturally_.|
|any-number||Sort column with mixed numerical content by number|
|monthYear||This sorting plug-in will sort, in calendar order, data whichis in the format "MM YY".Please note that this plug-in is **deprecated*. The[datetime](//datatables.net/blog/2014-12-18) plug-in provides enhancedfunctionality and flexibility.|
|file-size||Sort abbreviated file sizes correctly (8MB, 4KB, etc)|
|enum||Dynamically create enum sorting options for a DataTable|
|diacritics-sort||Better sort of strings containing accented characters (diacritical marks)|
|date-euro||Sort date / time in the format `dd/mm/YYYY hh:ii:ss`|
|stringMonthYear||This sorting plug-in will sort, in calendar order, data whichis in the format "MMM yyyy" or "MMMM yyyy". Inspired by forum discussion:http://datatables.net/forums/discussion/1242/sorting-dates-with-only-month-and-yearPlease note that this plug-in is **deprecated*. The[datetime](//datatables.net/blog/2014-12-18) plug-in provides enhancedfunctionality and flexibility.|
|natural-time-delta||Created by Shodhan Save on Jan 23, 2018.Updated @ Jan 25, 2018|
|date-de||Sort date / time in the format `dd.mm.YYYY HH:mm` or `dd.mm.YYYY`.|
|formatted-numbers||Sort numbers which are displayed with thousand separators|
|signed-num||Sort data numerically with a leading `+` symbol (as well as `-`).|
|alt-string||Use the `alt` attribute of an image tag as the data to sort upon.|
|numeric-comma||Sort numbers correctly which use a comma as the decimal place.|
|num-html||Sort data which is a mix of HTML and numeric data.|
|turkish-string||Sort Turkish characters|
|percent||Sort numeric data with a postfixed percentage symbol|
|anti-the||Sort with the prefixed word `dt-string The` removed, if present|
|chinese-string||Sort Chinese characters|
|currency||Sort data numerically when it has a leading currency symbol.|
|date-uk||Sort dates in the format `dd/mm/YY`|
|title-numeric||Sort data numerically based on an attribute on an empty element.|
|ip-address||Sort IP addresses numerically|
|datetime-moment||Sort date and time in any format using Moment.js|
|scientific||Sort data which is written in exponential notation.|
|title-string||Sort data as a string based on an attribute on an empty element.|
|brackets-negative||Detect data of currency type with a leading currency symbol as well at detect two types of negative number formatting|
|persian||Sort Persian strings alphabetically|
|absolute||Keep one or more items at the top and/or bottom of a table when sorting|
|time||Sort Times in the formats: `hh:mm, hh:mm:ss, hh:mm tt, hh:mm:ss tt`|
|date-eu||Sort dates in the format `dd/mm/YY[YY]` (with optional spaces)|
|date-dd-MMM-yyyy||Sort dates in the format `dd-mmm-yyyy`|
Custom data source sorting plug-ins allow complete control of the data that is to be sorted. Typically this is used to retrieve data live from the DOM just prior to the table being sorted, to perform sorting on data that can be updated by the end-user or by some other script.
You can also use type based sorting in-combination with custom data source sorting as the data returned by the custom data source sorting plug-in is processed in exactly the same way as automatically retrieved data.
Please note that custom data source sorting plug-ins will often query the DOM for information which can degrade performance. Thus, if it is possible for you to use type based sorting (above) or orthogonal data, it is recommended that you do so.
columns.orderDataType parameter for the column, to tell it which plug-in function to use.
The custom data source functions are used to update the cached data in DataTables, so sorting can occur on columns with user input information.
|dom-text||Sorting based on the values of `dt-tag input` elements in a column.|
|dom-select||Sort based on the value of the `dt-tag select` options in a column|
|dom-checkbox||Sort based on the checked state of checkboxes in a column|