Skip to content

Commit

Permalink
Fix: added sorting code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexappleget committed Oct 17, 2024
1 parent a894326 commit 1f6048e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions components/TableColumns/TableColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ export const leagueColumns: ColumnDef<IEntryWithLeague>[] = [
const survivors = row.getValue('survivors') as string[];
return <div>{survivors.length}</div>;
},
/**
* To be able to sort the row by numbers.
* @param rowA - Example 1 of survivors in a league.
* @param rowB - Example 2 of survivors in a league.
* @returns - Length of each participants league to be able to accurately sort.
*/
sortingFn: (rowA, rowB): number => {
const lengthA = (rowA.getValue('survivors') as string[]).length;
const lengthB = (rowB.getValue('survivors') as string[]).length;
return lengthA - lengthB;
},
},
{
accessorKey: 'participants',
Expand Down

0 comments on commit 1f6048e

Please sign in to comment.