Skip to content

Commit

Permalink
fix(DataTable): add sorting null values
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Hull committed Feb 15, 2023
1 parent fa8bb0e commit 88b3fae
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/react/src/components/DataTable/tools/sorting.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import { sortStates } from '../state/sortStates';
* @returns {number}
*/
export const compare = (a, b, locale = 'en') => {
// prevent multiple null values in one column (sorting breaks)
a === null ? (a = '') : null;
b === null ? (b = '') : null;

if (typeof a === 'number' && typeof b === 'number') {
return a - b;
}
Expand Down

0 comments on commit 88b3fae

Please sign in to comment.