sorting huge number
sorting huge number

i have problem in datatable sorting with huge number like this :
362516690048775976
362516690048775977
362516690048775978
362516690048775979
362516690048775980
362516690048775981
the sorting with huge number not working
thanks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
That number is larger than the Javascript MAX_SAFE_INTEGER value. They are likely being treated as strings which might not sort as expected. You may need to use orthogonal data and prefix leading
0
so all of the strings are the same length for thesort
operation.If you still need help please build a simple test case with an example of your data and the sorting problem.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
so the idea it's to change the column from string to integer ??
No. I am assuming you have different length numbers. If that is the case then the idea is to use
columns.render
to prefix the numbers with leading zeros so all strings are the same length. For example thesort
operation data should look like this:Kevin
I found this solution and it works but I don't know if it is a good solution or not
$('.datatable').dataTable( {
columnDefs: [
{ type: 'natural', targets: 3 }
]
} );
You found the Natural Sorting Plugin. Thats a good find.
Kevin
thanks for you're help and have a good day ^^