TanStack / TanStack/table

sortUndefined and Excel like sorting

Open
#6,061 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
28.4k
Forks
3.6k
Avg merge
1d 14h
Merged PRs (30d)
10

Description

TanStack Table version

8.21.3

Framework/Library version

React 18.2

Describe the bug and the steps to reproduce it

Hello and thanks for that fantastic library!
I have a question or a bug when creating an Excel like sorting. My problem is to get the null/undefined results always to the bottom of the table. I would have assumed that sortUndefined would do the trick but it did not. Therefore I tried to create a custom sorting for that. But I can not manage to geht the sorting correct.
Correct (Excel Like) would be, if my table could do that

Excel Behavior Supported in excelSortingFn?
Numbers before text ✅ Yes
Booleans in correct order ✅ Yes
Case-insensitive strings ✅ Yes
Empty/null values last ❌ Problem
No coercion of string "123" ✅ Yes

I added a simple code sandbox link below to try it out. Any help would be greatly appreciated.

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://codesandbox.io/p/sandbox/boring-ellis-sw7h86

Screenshots or Videos (Optional)

No response

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

No, because I do not know how

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox and the table's sortUndefined and excelSortingFn behavior. Reproduce the ordering problem with null or undefined values, then verify that the sorting keeps empty values last while preserving the listed Excel-like ordering rules.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.