Skip to content

Alphanumeric sorting is not accurate #6174

@marythrall

Description

@marythrall

TanStack Table version

8.21.3

Framework/Library version

React 19.1.0

Describe the bug and the steps to reproduce it

The alphanumeric table sorting appears to change how it sorts depending on the location in the word of the character in question.

For the first character in a word, the table does alphanumeric sort, with letters being sorted BEFORE numbers. This is strange, but is already reported in #5500.

This issue is different, is definitely a bug, and describes how the sort behavior changes mid-word.

The first character is sorted, as described above, alphanumerically with letters before numbers. However, subsequent characters are sorted differently and sometimes innacurately. One example provided below.

These two lists are what the table is currently showing as sorted ascending. This is incorrect.
apple1
apple2
appleA
appleB
banana1
banana2
1apple
1banana
2apple
2banana

This is what that list SHOULD look like, assuming alphanumeric sorting with letters coming before numbers. Note that the positions of the first four entries have changed from above.
appleA
appleB
apple1
apple2
banana1
banana2
1apple
1banana
2apple
2banana

This is what the list should look like if sorted alphanumerically where numbers come before letters. This is the ideal sort order, but since that point is already made in ticket 5500, I won't belabor it. Whether letters or numbers come first, this ticket is about keeping that ordering consistent regardless of where in the word the character is located. This list below is, for example, how a (literal physical book-filled) library would sort the items:
1apple
1banana
2apple
2banana
apple1
apple2
appleA
appleB
banana1
banana2

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

I don't have access to this

Screenshots or Videos (Optional)

Image

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

None

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions