Don't work sorting table

Don't work sorting table

mariog82mariog82 Posts: 1Questions: 1Answers: 0

Why the sorting column don't work with (ex.) 'dd/MM/yyyy' format date?

Answers

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    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

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    See this blog post for details on sorting date times in non-ISO8601 formats and an explanation of why this is required.

    Allan

This discussion has been closed.