i have a table with several integer values. If i sort by this column they get sorted like this: 9 8
i have a table with several integer values. If i sort by this column they get sorted like this: 9 8
charles19192
Posts: 3Questions: 1Answers: 0
i have a table with several integer values. If i sort by this column they get sorted like this:
9
8
6
5
3
22
21
20
2
19
18
17
etc...
It seems to be sorting by the first digit of the integer. Is there some setting i can use to fix this?
Answers
Sounds like your data is being sorted as a string not a number. Datatables does some type checking of the data in each column and for some reason set the column type to string. It would do this if you have non-numeric data in the column. Do you have non-numeric data in that column?
Kevin
yes Sir, there is non-numeric data in that column and It's a bracket. ()
I have taken the brackets off but the issue still persists.
Any ideas that might help?
thanks
Charles
Without a link to a test case showing the issue we can't say specifically what data value is causing the problem, but as Kevin noted, it will still be that there is non-numeric data in the column somewhere.
If you are using brackets for negative numbers, then this plug-in will sort them correctly for you. But we'd still need to identify any other data detected as non-numeric.
Allan
Thanks @ Allan,
please I'm new to this
can't I post a link
but can I post snippets of the code?
Try the plugin Allan linked to if your parenthesis are used for negative numbers. If that doesn't help then we will need to see something that shows all the different examples of non-numeric data you have. We need to understand what your non-numeric data is and how you want to handle it for sorting to offer other suggestions. The best way to do this is to create a test case with sample data that we can look at.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Another option is to use Orthogonal data to remove the non-numeric characters using
columns.render
for the sort operation.Kevin