gridjs

Sorting by integer column doesn't sort by amount. Is it possible?


My data:

  data: [
  ["A","2"],
  ["B","100"],
  ]

I was expecting it to sort by amount: 2 then 100, but it's the opposite. First row shows 100, second row shows 2. Is there a way to sort by the actual amount rather than this numeric ordering?


Solution

  • As "2" and "100" are interpreted as string - the sort order is alphanumeric instead of numeric.

    Try

    data: [
      ["A",2],
      ["B",100],
    ]
    

    instead to sort by the numbers.