File tree 2 files changed +11
-11
lines changed
2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ export const Sorting: TableFeature = {
116
116
getDefaultColumnDef : < TData extends RowData > ( ) : SortingColumnDef < TData > => {
117
117
return {
118
118
sortingFn : 'auto' ,
119
+ sortUndefined : 1 ,
119
120
}
120
121
} ,
121
122
Original file line number Diff line number Diff line change @@ -53,32 +53,31 @@ export function getSortedRowModel<TData extends RowData>(): (
53
53
const columnInfo = columnInfoById [ sortEntry . id ] !
54
54
const isDesc = sortEntry ?. desc ?? false
55
55
56
+ let sortInt = 0
57
+
58
+ // All sorting ints should always return in ascending order
56
59
if ( columnInfo . sortUndefined ) {
57
60
const aValue = rowA . getValue ( sortEntry . id )
58
61
const bValue = rowB . getValue ( sortEntry . id )
59
62
60
- const aUndefined = typeof aValue === ' undefined'
61
- const bUndefined = typeof bValue === ' undefined'
63
+ const aUndefined = aValue === undefined
64
+ const bUndefined = bValue === undefined
62
65
63
66
if ( aUndefined || bUndefined ) {
64
- let undefinedSort =
67
+ sortInt =
65
68
aUndefined && bUndefined
66
69
? 0
67
70
: aUndefined
68
71
? columnInfo . sortUndefined
69
72
: - columnInfo . sortUndefined
70
-
71
- if ( isDesc && undefinedSort !== 0 ) {
72
- undefinedSort *= - 1
73
- }
74
-
75
- return undefinedSort
76
73
}
77
74
}
78
75
79
- // This function should always return in ascending order
80
- let sortInt = columnInfo . sortingFn ( rowA , rowB , sortEntry . id )
76
+ if ( sortInt === 0 ) {
77
+ sortInt = columnInfo . sortingFn ( rowA , rowB , sortEntry . id )
78
+ }
81
79
80
+ // If sorting is non-zero, take care of desc and inversion
82
81
if ( sortInt !== 0 ) {
83
82
if ( isDesc ) {
84
83
sortInt *= - 1
You can’t perform that action at this time.
0 commit comments