fix: alpha sort by labelPlural primary, symbol secondary
Handles ties like 'Barrel (US fluid)' vs 'Barrel (US dry)'
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
"symbol": "dl",
|
"symbol": "dl",
|
||||||
"group": "dickloads",
|
"group": "dickloads",
|
||||||
"toBase": 1,
|
"toBase": 1,
|
||||||
"description": "See {pound:description}"
|
"description": "See {pound:description}. Let's also look at {us-oil-bbl}."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "pound",
|
"id": "pound",
|
||||||
@@ -19,10 +19,10 @@
|
|||||||
"description": "My description is {dickload:description}"
|
"description": "My description is {dickload:description}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "barrel",
|
"id": "us-oil-bbl",
|
||||||
"label": "barrel",
|
"label": "oil barrel (US)",
|
||||||
"labelPlural": "barrels",
|
"labelPlural": "oil barrels (US)",
|
||||||
"symbol": "bbl",
|
"symbol": "us oil bbl",
|
||||||
"group": "dickloads",
|
"group": "dickloads",
|
||||||
"toBase": 13.3192584,
|
"toBase": 13.3192584,
|
||||||
"description": "Weight is based on pure water at 4 degrees celsius.",
|
"description": "Weight is based on pure water at 4 degrees celsius.",
|
||||||
@@ -106,26 +106,35 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "us-fluid-bbl",
|
"id": "us-fluid-bbl",
|
||||||
"label": "US fluid barrel",
|
"label": "barrel",
|
||||||
"labelPlural": "US fluid barrels",
|
"labelPlural": "barrels",
|
||||||
"symbol": "us fluid bbl",
|
"symbol": "us fluid bbl",
|
||||||
"group": "dickloads",
|
"group": "dickloads",
|
||||||
"toBase": 9.9894438
|
"toBase": 9.9894438
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "us-dry-bbl",
|
"id": "us-dry-bbl",
|
||||||
"label": "US dry barrel",
|
"label": "dry barrel",
|
||||||
"labelPlural": "US dry barrels",
|
"labelPlural": "dry barrels",
|
||||||
"symbol": "us dry bbl",
|
"symbol": "us dry bbl",
|
||||||
"group": "dickloads",
|
"group": "dickloads",
|
||||||
"toBase": 1
|
"toBase": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "us-hogshead",
|
||||||
|
"label": "hogshead (US)",
|
||||||
|
"labelPlural": "hogsheads (US)",
|
||||||
|
"symbol": "us hhd",
|
||||||
|
"group": "dickloads",
|
||||||
|
"toBase": 19.9788876,
|
||||||
|
"description": "Equal to two US fluid barrels."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
{
|
||||||
"id": "dickloads",
|
"id": "dickloads",
|
||||||
"label": "Weights and Masses",
|
"label": "Weights and Masses",
|
||||||
"baseUnitId": "",
|
"baseUnitId": "dickload",
|
||||||
"toUniversal": 1,
|
"toUniversal": 1,
|
||||||
"sortOrder": "alpha",
|
"sortOrder": "alpha",
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
|
|||||||
@@ -153,7 +153,10 @@
|
|||||||
const items = byGroup.get(group.id);
|
const items = byGroup.get(group.id);
|
||||||
if (items?.length) {
|
if (items?.length) {
|
||||||
const sorted = group.sortOrder === 'alpha'
|
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;
|
: items;
|
||||||
sections.push({ groupLabel: group.label, alwaysShowLabel: group.alwaysShowLabel ?? false, items: sorted });
|
sections.push({ groupLabel: group.label, alwaysShowLabel: group.alwaysShowLabel ?? false, items: sorted });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user