broken sort, only sorts first 2 digits
broken sort, only sorts first 2 digits
Hey,
i can't find any solution. sorting my table results for example in this order:
0.1
10.8
10.20
103.20
108.50
11.30
11.2
i convertet the csv input with php to float.
it seems he only sort the frist 2 digits. Anyone knows how to fix this problem?
thx mike
i can't find any solution. sorting my table results for example in this order:
0.1
10.8
10.20
103.20
108.50
11.30
11.2
i convertet the csv input with php to float.
it seems he only sort the frist 2 digits. Anyone knows how to fix this problem?
thx mike
This discussion has been closed.
Replies
same happens when i cut out the decimal places...
only the first digits are sorted...
My guess is that you have white space in the table cell. In order to sort numerically, DataTables requires that you have only numeric ( [0-9]\-\. ) in the cell, otherwise it will be sorted as a string - which is what is happening here.
So remove any white space and any other non-numeric data and it will work fine.
If you don't want to remove the white space etc, then you can use the sorting plug-in "formatted numbers" ( http://datatables.net/plug-ins/sorting#formatted_numbers ) which will strip these non-numeric characters for you. The disadvantage of this is that sorting is slightly slower due to the additional processing.
Regards,
Allan