I’d like to propose an improvement to the sorting logic inside specNameSorter.
The current case 6 sorts by name (A–Z) and then by type.
This works, but it produces unstable ordering when multiple specialists share the same name and type, their relative order becomes effectively random.
I’d like to suggest replacing case 6 with this method:
Name (A–Z) --- Type (ascending) --- Unique ID (ascending)
This keeps the alphabetical behavior but ensures consistent ordering like it is in the Star menu.
Here is the proposed replacement for case 6:
case 6:
var nameA = a.getName(false).replace(/(<([^>]+)>)/gi, "").toLowerCase(),
nameB = b.getName(false).replace(/(<([^>]+)>)/gi, "").toLowerCase(),
res = nameA.localeCompare(nameB);
if(res != 0) return res;
if(a.GetType() < b.GetType()) return -1;
if(a.GetType() > b.GetType()) return 1;
var aID = a.GetUniqueID(),
bID = b.GetUniqueID();
if(aID.uniqueID1 < bID.uniqueID1) return -1;
if(aID.uniqueID1 > bID.uniqueID1) return 1;
if(aID.uniqueID2 < bID.uniqueID2) return -1;
if(aID.uniqueID2 > bID.uniqueID2) return 1;
return 0;
break;
I’d like to propose an improvement to the sorting logic inside specNameSorter.
The current case 6 sorts by name (A–Z) and then by type.
This works, but it produces unstable ordering when multiple specialists share the same name and type, their relative order becomes effectively random.
I’d like to suggest replacing case 6 with this method:
Name (A–Z) --- Type (ascending) --- Unique ID (ascending)
This keeps the alphabetical behavior but ensures consistent ordering like it is in the Star menu.
Here is the proposed replacement for case 6: