From d9274fb96483c3950a9aab6fbc37542c37228dad Mon Sep 17 00:00:00 2001 From: Sebastian Sebald Date: Mon, 18 Sep 2023 20:04:51 +0200 Subject: [PATCH] fix: sort longshanks players by rank --- app/api/longshanks/[id]/players/route.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/api/longshanks/[id]/players/route.ts b/app/api/longshanks/[id]/players/route.ts index 851cf1e4..2a956bbf 100644 --- a/app/api/longshanks/[id]/players/route.ts +++ b/app/api/longshanks/[id]/players/route.ts @@ -149,5 +149,12 @@ export const GET = async (_: NextRequest, { params }: RouteContext) => { }; }); + players.sort((a, b) => { + if (a.rank.elimination || b.rank.elimination) { + return (a.rank.elimination ?? 1000) - (b.rank.elimination ?? 1000); + } + return a.rank.swiss - b.rank.swiss; + }); + return NextResponse.json(players); };