Skip to content

Commit cb563bb

Browse files
authored
Update default-sort-compare.js
1 parent 455f2a6 commit cb563bb

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/components/table/helpers/default-sort-compare.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,18 @@ export default function defaultSortCompare(a, b, sortBy) {
1515
(typeof a === 'number' && typeof b === 'number')
1616
) {
1717
// Special case for comparing Dates and Numbers
18-
return (a < b && -1) || (a > b && 1) || 0
18+
// Internally dates are compared via their epoch number values
19+
if (a < b) {
20+
return -1
21+
} else if (a > b) {
22+
return 1
23+
} else {
24+
return 0
25+
}
26+
} else {
27+
// Do localized string comparison
28+
return stringifyObjectValues(a).localeCompare(stringifyObjectValues(b), undefined, {
29+
numeric: true
30+
})
1931
}
20-
return stringifyObjectValues(a).localeCompare(stringifyObjectValues(b), undefined, {
21-
numeric: true
22-
})
2332
}

0 commit comments

Comments
 (0)