diff --git a/app/components/standings/TeamScoreBreakdown.tsx b/app/components/standings/TeamScoreBreakdown.tsx
index 8978135..265a5f2 100644
--- a/app/components/standings/TeamScoreBreakdown.tsx
+++ b/app/components/standings/TeamScoreBreakdown.tsx
@@ -39,7 +39,7 @@ interface TeamScoreBreakdownProps {
} | null;
}
-type SortColumn = "pick" | "points";
+type SortColumn = "pick" | "points" | "sport" | "participant";
type SortDirection = "asc" | "desc";
function SortIndicator({ column, sortColumn, sortDirection }: { column: SortColumn; sortColumn: SortColumn; sortDirection: SortDirection }) {
@@ -49,16 +49,45 @@ function SortIndicator({ column, sortColumn, sortDirection }: { column: SortColu
: ;
}
+function SortableHeader({ column, label, sortColumn, sortDirection, onSort, className }: {
+ column: SortColumn;
+ label: string;
+ sortColumn: SortColumn;
+ sortDirection: SortDirection;
+ onSort: (column: SortColumn) => void;
+ className?: string;
+}) {
+ return (
+
+ );
+}
+
+const cmp = (a: string, b: string) => a.localeCompare(b, undefined, { sensitivity: "base" });
+
function sortPicks(
picks: TeamScoreBreakdownProps["breakdown"]["picks"],
sortColumn: SortColumn,
sortDirection: SortDirection,
) {
const dir = sortDirection === "asc" ? 1 : -1;
- return picks.slice().sort((a, b) => {
+ return picks.toSorted((a, b) => {
if (sortColumn === "pick") {
return (a.pickNumber - b.pickNumber) * dir;
}
+ if (sortColumn === "sport") {
+ const sportCmp = cmp(a.participant.sport, b.participant.sport) * dir;
+ if (sportCmp !== 0) return sportCmp;
+ return cmp(a.participant.name, b.participant.name) * dir;
+ }
+ if (sortColumn === "participant") {
+ return cmp(a.participant.name, b.participant.name) * dir;
+ }
// points: sort by actual first, then projected
const pointsDiff = a.points - b.points;
if (pointsDiff !== 0) return pointsDiff * dir;
@@ -142,16 +171,14 @@ export function TeamScoreBreakdown({
-
+
+
+
+
+
+
+
- Sport
- Participant
Position