From 9104d7bdeef92806a3da7fbc4f11c206f42ef2cb Mon Sep 17 00:00:00 2001 From: posadist-revolution Date: Wed, 17 Dec 2025 20:27:17 -0700 Subject: [PATCH] Sort currencies by name and exchange rate for better change generation --- scripts/currency.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/scripts/currency.js b/scripts/currency.js index 92e6df5..a3df640 100644 --- a/scripts/currency.js +++ b/scripts/currency.js @@ -59,7 +59,17 @@ function getManualSpheres() { currencies.find(value => value.name === "Diamond Mark").primary = true; - return currencies; + currencies.sort(function(a, b) { + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } + return 0; + }); + + return currencies.sort((a, b) => b.exchangeRate - a.exchangeRate); } async function getCompendiumSpheres() { @@ -85,7 +95,16 @@ async function getCompendiumSpheres() { exchangeRate: itemData.system.price.value, }); } - if(currencies.length > 0) return currencies; + currencies.sort(function(a, b) { + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } + return 0; + }); + if(currencies.length > 0) return currencies.sort((a, b) => b.exchangeRate - a.exchangeRate); } return null; }