Search code examples
tabulator

Tabulator Sorting Numbers


I am sorting by a column with numbers in. I understand why the sorting puts 8.10 before 8.2, however is there a way to overcome this? I don't really want to have to ut 8.01 etc

I did try all the sort types but none gave the desired results

enter image description here


Solution

  • That looks like you are sorting the column as a string rather than a number, though i wouldnt be able to say for sure without a JS Fiddle to demonstrate the issue.

    The solution is to set the sorter to number in the columns definition object. In the example below i am going to assume the column is called score:

    {title:"Score", field:"score", sorter:"number"}
    

    That should the correctly sort by number