@tanstack/react-table 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.
@@ -2340,7 +2340,8 @@
2340
2340
  },
2341
2341
  getDefaultColumnDef: () => {
2342
2342
  return {
2343
- sortingFn: 'auto'
2343
+ sortingFn: 'auto',
2344
+ sortUndefined: 1
2344
2345
  };
2345
2346
  },
2346
2347
  getDefaultOptions: table => {
@@ -3387,22 +3388,23 @@
3387
3388
  const sortEntry = availableSorting[i];
3388
3389
  const columnInfo = columnInfoById[sortEntry.id];
3389
3390
  const isDesc = (_sortEntry$desc = sortEntry == null ? void 0 : sortEntry.desc) != null ? _sortEntry$desc : false;
3391
+ let sortInt = 0;
3392
+
3393
+ // All sorting ints should always return in ascending order
3390
3394
  if (columnInfo.sortUndefined) {
3391
3395
  const aValue = rowA.getValue(sortEntry.id);
3392
3396
  const bValue = rowB.getValue(sortEntry.id);
3393
- const aUndefined = typeof aValue === 'undefined';
3394
- const bUndefined = typeof bValue === 'undefined';
3397
+ const aUndefined = aValue === undefined;
3398
+ const bUndefined = bValue === undefined;
3395
3399
  if (aUndefined || bUndefined) {
3396
- let undefinedSort = aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
3397
- if (isDesc && undefinedSort !== 0) {
3398
- undefinedSort *= -1;
3399
- }
3400
- return undefinedSort;
3400
+ sortInt = aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
3401
3401
  }
3402
3402
  }
3403
+ if (sortInt === 0) {
3404
+ sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
3405
+ }
3403
3406
 
3404
- // This function should always return in ascending order
3405
- let sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
3407
+ // If sorting is non-zero, take care of desc and inversion
3406
3408
  if (sortInt !== 0) {
3407
3409
  if (isDesc) {
3408
3410
  sortInt *= -1;