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

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

Fix #479
  • Loading branch information
aVileBroker committed Nov 15, 2023
1 parent 40cc3d3 commit de312b9
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 de312b9

Please sign in to comment.