I have a column that is numbered .. 1, 2, 3, 4,...8, 9, 10. 11, 12, etc
I would expect when sorted it would sort 1-12.
Instead I get it sorts like this:
1, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 9
I wouldn't think this is the intention, am I wrong?
First check to ensure your number is actually a number and not a string. A string will not sort numerically and would need to be converted to a number (similarly with dates). For example:
{
Header: 'Record Number',
id: 'recordNumber',
accessor: d=>Number(d.recordNumber),
},
NOTE: you require id because the accessor needs to be a function (and react-table actually operates on the id internally but usually creates it from the accessor if it is string-based).
Other than that, I can't really say what would be wrong without a working example of the problem.
I also suggest you join the #react-table channel on Slack. The github issues are only monitored by a small group of people that are trying to triage the requests. The Slack channel is full of a lot of developers using react-table in various stack environments. There is a badge at the top of the README in the doco. Thanks.
@gary-menzel what if we have data like version numbers ['1.0.6', '1.0.8', '17.9.1'] how could you suggest sorting here? Please let me know
Most helpful comment
First check to ensure your number is actually a number and not a string. A string will not sort numerically and would need to be converted to a number (similarly with dates). For example:
NOTE: you require
idbecause theaccessorneeds to be a function (and react-table actually operates on theidinternally but usually creates it from theaccessorif it is string-based).Other than that, I can't really say what would be wrong without a working example of the problem.
I also suggest you join the #react-table channel on Slack. The github issues are only monitored by a small group of people that are trying to triage the requests. The Slack channel is full of a lot of developers using react-table in various stack environments. There is a badge at the top of the README in the doco. Thanks.