Open barberob opened 2 months ago
Running into the same issue. I searched the coding of Gridjs and looked for a way to set a custom sorter for a from
-table generated table like documented in https://gridjs.io/docs/config/sort#column-specific-sort-config, but did not found a solution for this. Is there a way to configure column specific sorting when using from
?
Would like an answer on this one if possible 👍
@barberob @matzeeable it sounds like you are trying to perform a numeric comparison without using a custom comparator function. In JavaScript array.sort()
converts the elements of the array to strings and then compares their sequences of UTF-16 code unit values (lexicographical, not numerical). In order to achieve the desired result, you must use a custom comparator function to achieve numeric sorting.
@afshinm one thing you could probably change is to first check if the values being sorted are numeric, but that will likely come with its own challenges, especially considering there is already a way to achieve numeric sorting with a custom comparator function.
Describe the bug The sorting is wrong on numbers when creating
from
an html table.To Reproduce Steps to reproduce the behavior:
Expected behavior This should sort it like a number 1, 2, 3, 4 becomes 4, 3, 2, 1
Screenshots
Desktop / Smartphone not os specific