Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sortingFn: 'alphanumeric' returns numbers last #5500

Open
2 tasks done
jessewriter opened this issue Apr 19, 2024 · 1 comment
Open
2 tasks done

sortingFn: 'alphanumeric' returns numbers last #5500

jessewriter opened this issue Apr 19, 2024 · 1 comment

Comments

@jessewriter
Copy link

jessewriter commented Apr 19, 2024

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

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
@jessewriter
Copy link
Author

jessewriter commented Apr 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant