Don't work sorting table
Don't work sorting table
mariog82
Posts: 1Questions: 1Answers: 0
Why the sorting column don't work with (ex.) 'dd/MM/yyyy' format date?
This discussion has been closed.
Answers
How are you expecting it to sorted? by dd? or by yyyy - mm - dd?
For most sorting methods, you need to define the "type" of the column data if it's not pure ascii sorting. A column formatted "yyyy/mm/dd" will always sort correctly, but "yyyy/m/d" will not (because of missing leading zeros in month and date).
See this topic.
https://datatables.net/reference/option/columns.type
I haven't looked at sorting too much in 1.10 and any enhancements that were implemented, but I used to (and still do) use a plugin called "natural" which seems to get it correct most of the time.
http://js-naturalsort.googlecode.com/svn/trunk/naturalSort.js
See this blog post for details on sorting date times in non-ISO8601 formats and an explanation of why this is required.
Allan