Sorting a column with mixed values

Sorting a column with mixed values

skallajeskallaje Posts: 1Questions: 1Answers: 0
edited March 11 in Free community support

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

  • kthorngrenkthorngren Posts: 20,342Questions: 26Answers: 4,775

    One option is to use Orthogonal data to set the sort operation to the desired value. You could use columns.render to replace all - with 0 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

Sign In or Register to comment.