Sorting a column with mixed values
Sorting a column with mixed values
skallaje
Posts: 1Questions: 1Answers: 0
dataTables is not sorting a column containing mixed values (numbers and multiple dashes (---)) properly. For example, dashes should be treated as 0 and must be present at the top when sorted in ascending order. But, it's at the top when sorted in descending order currently. BTW, this problem doesn't occur when we use single dash.
I am using type: "num-fmt" for the concerned columns. It didn't help. Tried "html-num-fmt" too, but no luck there as well.
Answers
One option is to use Orthogonal data to set the
sort
operation to the desired value. You could usecolumns.render
to replace all-
with0
for sorting. WIthout seeing a test case with your data its hard to say if that will result in those values being sorted to the top.Another option might be to use the Natural sorting plugin. Or you will need to create your own sorting plugin to handle the values with dashes in the manner you want.
Kevin