fix: alpha sort by labelPlural primary, symbol secondary

Handles ties like 'Barrel (US fluid)' vs 'Barrel (US dry)'
This commit is contained in:
Falkan
2026-03-18 21:13:17 -04:00
parent 1c6dc7984a
commit 8ec935d238
2 changed files with 23 additions and 11 deletions

View File

@@ -153,7 +153,10 @@
const items = byGroup.get(group.id);
if (items?.length) {
const sorted = group.sortOrder === 'alpha'
? [...items].sort((a, b) => a.unit.label.localeCompare(b.unit.label))
? [...items].sort((a, b) => {
const labelCmp = a.unit.labelPlural.localeCompare(b.unit.labelPlural);
return labelCmp !== 0 ? labelCmp : a.unit.symbol.localeCompare(b.unit.symbol);
})
: items;
sections.push({ groupLabel: group.label, alwaysShowLabel: group.alwaysShowLabel ?? false, items: sorted });
}