From 30c866ffc0c02900a2862559c265a71472844008 Mon Sep 17 00:00:00 2001 From: Abdellah Hariti Date: Thu, 29 Feb 2024 14:30:38 +0100 Subject: [PATCH] fix: sort platforms in dropdown in alphabetical order --- src/components/home.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/home.tsx b/src/components/home.tsx index 3296d60b00dc3..bc521b12236d2 100644 --- a/src/components/home.tsx +++ b/src/components/home.tsx @@ -54,6 +54,15 @@ export async function Home() { (a, b) => HIGHLIGHTED_PLATFORMS.indexOf(a.key) - HIGHLIGHTED_PLATFORMS.indexOf(b.key) ); + // this regex deals with names like .NET that would otherwise be sorted at the top + const leadingNonAlphaRegex = /^[^\w]/; + + platformList.sort((a, b) => + (a.title ?? a.name) + .replace(leadingNonAlphaRegex, '') + .localeCompare((b.title ?? b.name).replace(leadingNonAlphaRegex, '')) + ); + return (