DataTables Sorting plugins

Certain data types, like currency or percentage values, or European dates, need special attention when they are sorted. To use such data types with TablePress and the used DataTables JavaScript library, just install and activate the DataTables Sorting plugins Extension like a regular WordPress plugin.

Currencies, Percentage values, Dates

Data types like formatted numbers (e.g. with a thousand separator like in 100’000), currencies ($, €, £) or percentage values (%), European date formats (dd.mm(.yyyy) or dd/mm(/yyyy)) will then be recognized automatically, so that they are sorted correctly.

Comma as the decimal separator

If you wan’t to sort numbers that use the comma “,” as the decimal separator (instead of the point “.”), there’s a sorting routine for that as well. However, it is not invoked automatically, but needs to be activated for each column manually, by adding the following code to the “Custom Commands” textfield in the “Features of the DataTables JavaScript library” section on the “Edit” screen of the table:

"aoColumnDefs": [ { "sType": "numeric-comma", "aTargets": [ 2, 3 ] } ]

The 2, 3 in that code is a zero-based list of all columns that shall be sorted as values with commas as the decimal separator. Here, 2, 3 means that the third and fourth column are sorted like this, as the counting starts with 0 for the first column.

If this Extension is helpful for you, please consider supporting further TablePress development with a donation. Thank you!


Note: For sorting numbers in HTML links, please see the DataTables HTML Numbers in Tables Extension.

Top