Skip to content

Commit

Permalink
fix(DataTable): add sorting null values (#13161)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
jsehull and kodiakhq[bot] committed Feb 16, 2023
1 parent e4e1c0f commit a719141
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 a719141

Please sign in to comment.