Skip to content

Commit 634a681

Browse files
authored
fix: sort platforms in dropdown in alphabetical order (#9287)
1 parent ce55e96 commit 634a681

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/components/home.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ export async function Home() {
5454
(a, b) => HIGHLIGHTED_PLATFORMS.indexOf(a.key) - HIGHLIGHTED_PLATFORMS.indexOf(b.key)
5555
);
5656

57+
// this regex deals with names like .NET that would otherwise be sorted at the top
58+
const leadingNonAlphaRegex = /^[^\w]/;
59+
60+
platformList.sort((a, b) =>
61+
(a.title ?? a.name)
62+
.replace(leadingNonAlphaRegex, '')
63+
.localeCompare((b.title ?? b.name).replace(leadingNonAlphaRegex, ''))
64+
);
65+
5766
return (
5867
<HomeClient
5968
visiblePlatforms={visiblePlatforms}

0 commit comments

Comments
 (0)