MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / compareSortValues

Function compareSortValues

packages/core/src/widgets/useTable.ts:62–87  ·  view source on GitHub ↗
(a: unknown, b: unknown)

Source from the content-addressed store, hash-verified

60}
61
62function compareSortValues(a: unknown, b: unknown): number {
63 if (a === b) return 0;
64 if (a === undefined || a === null) return 1;
65 if (b === undefined || b === null) return -1;
66
67 if (typeof a === "number" && typeof b === "number") {
68 if (Number.isNaN(a) && Number.isNaN(b)) return 0;
69 if (Number.isNaN(a)) return 1;
70 if (Number.isNaN(b)) return -1;
71 return a - b;
72 }
73
74 if (typeof a === "boolean" && typeof b === "boolean") {
75 return Number(a) - Number(b);
76 }
77
78 if (a instanceof Date && b instanceof Date) {
79 return a.getTime() - b.getTime();
80 }
81
82 const as = String(a);
83 const bs = String(b);
84 if (as < bs) return -1;
85 if (as > bs) return 1;
86 return 0;
87}
88
89function sortRows<T>(
90 rows: readonly T[],

Callers 1

sortRowsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected