@tanstack/table-core 8.9.2 → 8.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2305,7 +2305,8 @@ const Sorting = {
2305
2305
  },
2306
2306
  getDefaultColumnDef: () => {
2307
2307
  return {
2308
- sortingFn: 'auto'
2308
+ sortingFn: 'auto',
2309
+ sortUndefined: 1
2309
2310
  };
2310
2311
  },
2311
2312
  getDefaultOptions: table => {
@@ -3353,22 +3354,23 @@ function getSortedRowModel() {
3353
3354
  const sortEntry = availableSorting[i];
3354
3355
  const columnInfo = columnInfoById[sortEntry.id];
3355
3356
  const isDesc = (_sortEntry$desc = sortEntry == null ? void 0 : sortEntry.desc) != null ? _sortEntry$desc : false;
3357
+ let sortInt = 0;
3358
+
3359
+ // All sorting ints should always return in ascending order
3356
3360
  if (columnInfo.sortUndefined) {
3357
3361
  const aValue = rowA.getValue(sortEntry.id);
3358
3362
  const bValue = rowB.getValue(sortEntry.id);
3359
- const aUndefined = typeof aValue === 'undefined';
3360
- const bUndefined = typeof bValue === 'undefined';
3363
+ const aUndefined = aValue === undefined;
3364
+ const bUndefined = bValue === undefined;
3361
3365
  if (aUndefined || bUndefined) {
3362
- let undefinedSort = aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
3363
- if (isDesc && undefinedSort !== 0) {
3364
- undefinedSort *= -1;
3365
- }
3366
- return undefinedSort;
3366
+ sortInt = aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
3367
3367
  }
3368
3368
  }
3369
+ if (sortInt === 0) {
3370
+ sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
3371
+ }
3369
3372
 
3370
- // This function should always return in ascending order
3371
- let sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
3373
+ // If sorting is non-zero, take care of desc and inversion
3372
3374
  if (sortInt !== 0) {
3373
3375
  if (isDesc) {
3374
3376
  sortInt *= -1;