Skip to content

Commit

Permalink
fix(table): default table sorting now correctly ignores capitalized l…
Browse files Browse the repository at this point in the history
…etters in sort (#489)

Previously, the table would put all capitalized words ahead of
lowercased words

Fix #479
  • Loading branch information
aVileBroker authored Nov 15, 2023
2 parents 40cc3d3 + de312b9 commit 1069d90
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,14 @@ const Table = ({
}

// No sort function, use default comparison operator.
if (typeof entry1 === 'string' && typeof entry2 === 'string') {
const comparison =
sortDirection === SortDirection.ascending
? entry1.toLocaleLowerCase() < entry2.toLocaleLowerCase()
: entry1.toLocaleLowerCase() > entry2.toLocaleLowerCase();
return comparison ? -1 : 1;
}

const comparison =
sortDirection === SortDirection.ascending ? entry1 < entry2 : entry1 > entry2;
return comparison ? -1 : 1;
Expand Down

0 comments on commit 1069d90

Please sign in to comment.