From 397e12d9d00e6ab250445f2b373ce16cdf807c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Burkard?= <22095555+JeromeBu@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:27:43 +0100 Subject: [PATCH] sort category filter alphabetically. Fixes #74 --- .../softwareCatalog/SoftwareCatalogSearch.tsx | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/ui/pages/softwareCatalog/SoftwareCatalogSearch.tsx b/src/ui/pages/softwareCatalog/SoftwareCatalogSearch.tsx index 442ee0b1..57d60cf4 100644 --- a/src/ui/pages/softwareCatalog/SoftwareCatalogSearch.tsx +++ b/src/ui/pages/softwareCatalog/SoftwareCatalogSearch.tsx @@ -216,16 +216,24 @@ export function SoftwareCatalogSearch(props: Props) { "label": tCommon("allFeminine"), "value": "" }, - ...categoryOptions.map(({ category, softwareCount }) => ({ - "value": category, - "label": `${ - lang === "fr" - ? softwareCategoriesFrBySoftwareCategoryEn[ - category - ] ?? category - : category - } (${softwareCount})` - })) + ...categoryOptions + .map(({ category, softwareCount }) => ({ + "value": category, + "label": `${ + lang === "fr" + ? softwareCategoriesFrBySoftwareCategoryEn[ + category + ] ?? category + : category + } (${softwareCount})` + })) + .sort((a, b) => { + const labelA = a.label.toLowerCase(); + const labelB = b.label.toLowerCase(); + if (labelA < labelB) return -1; + if (labelA > labelB) return 1; + return 0; + }) ]} />