Repository navigation
Issue: Sorting null values to the bottom in @tanstack-table #5930
Replies: 1 comment
|
For TanStack Table v8, return {
id: 'name',
header: 'Name',
accessorFn: row => row.name ?? undefined,
sortingFn: 'text',
sortUndefined: 'last',
}The accessor leaves the original data alone and keeps empty strings intact. The v8 sorted row model checks for One edge case in v8.21.3: if two names are missing, the same branch returns before a secondary sort can run. If you need to sort the missing rows by another column, prepend a hidden sort column with |
Uh oh!
There was an error while loading. Please reload this page.
Hello everyone! I hope you're all doing well.
I've been struggling with a sorting issue in @tanstack-table for a few days and haven't found a solution yet.
I'm sorting a table on the client side, but when some users have null names and I apply descending (desc) sorting, these null values appear at the top of the list. Ideally, I would like them to always be placed at the bottom, regardless of the sorting direction, so they don't interfere with the natural order of the data.
I've tried the solution mentioned in this issue: #4289, but unfortunately, it didn't work for me.
Is there a recommended way to ensure that null or undefined values always appear at the end of the list when sorting?
Any help would be greatly appreciated! Thanks in advance. 😊

All reactions