From 4d7a2ed15101d1a6c811f656329a785ad4c97976 Mon Sep 17 00:00:00 2001 From: Timothy Armes Date: Tue, 19 Sep 2023 16:39:49 +0200 Subject: [PATCH] Sort players alphabetically --- app/[locale]/elo/page.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/[locale]/elo/page.tsx b/app/[locale]/elo/page.tsx index 9ad6bef..746b06e 100644 --- a/app/[locale]/elo/page.tsx +++ b/app/[locale]/elo/page.tsx @@ -3,7 +3,7 @@ import { useState } from "react"; import { zodResolver } from "@hookform/resolvers/zod"; -import { isEmpty } from "lodash"; +import { isEmpty, sortBy } from "lodash"; import { useTranslations } from "next-intl"; import Link from "next/link"; import { FormProvider, useForm } from "react-hook-form"; @@ -54,10 +54,13 @@ export default function Elo() { }, ); - const playerOptions = (allResults ?? []).map((player) => ({ - value: player.id, - label: player.name, - })); + const playerOptions = sortBy( + (allResults ?? []).map((player) => ({ + value: player.id, + label: player.name, + })), + "label", + ); const form = useForm({ resolver: zodResolver(fetchTournamentResultsSchema),