fix: alpha sort by labelPlural primary, symbol secondary
Handles ties like 'Barrel (US fluid)' vs 'Barrel (US dry)'
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user