TanStack / table

🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
https://tanstack.com/table
MIT License
24.51k stars 3.03k forks source link

sortingFn: 'alphanumeric' returns numbers last #5500

Open jessewriter opened 2 months ago

jessewriter commented 2 months ago

TanStack Table version

8.14.0

Framework/Library version

React 18.2

Describe the bug and the steps to reproduce it

expected behavior is for sorting to put symbols, numbers, followed by letters.

what i see is letters first with numbers last

example.

Amy Frank 1dude

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

propriatary code sorry

Screenshots or Videos (Optional)

column def { id: stationCode, accessorFn: (row) => ${row.x}::${row.y} sortingFn: 'alphanumeric', }

default sorting def defaultSorting={[{ id: 'stationCode', desc: false }]}

Do you intend to try to help solve this bug with your own PR?

Maybe, I'll investigate and start debugging

how i solved : sortingFn: (rowA, rowB, columnId) => { console.log('rowA', rowA.getValue('stationCode')) return rowA .getValue('stationCode') .localeCompare(rowB.getValue('stationCode'), 'en', { numeric: true }) },

Terms & Code of Conduct

jessewriter commented 2 months ago

interesting when i click the sorting from the header and disable sorting on this column it sorts correctly :/ , that may be because our data is pre-sorted correctly