diff --git a/client/src/panels/unitlistpanel.ts b/client/src/panels/unitlistpanel.ts index 6132cf9d..f03721b6 100644 --- a/client/src/panels/unitlistpanel.ts +++ b/client/src/panels/unitlistpanel.ts @@ -68,7 +68,7 @@ export class UnitListPanel extends Panel { "callback": () => { this.toggle() }, - "code": "Quote" + "code": "KeyU" }); this.startUpdates(); @@ -86,14 +86,18 @@ export class UnitListPanel extends Panel { this.#units = Object.values( this.#olympusApp.getUnitsManager().getUnits() ); - if ( this.#currentSortAlgorithm === "unitName" ) { - this.#sortUnitsByUnitName(); + if ( this.#currentSortAlgorithm === "coalition" ) { + this.#sortUnitsByCoalition(); } if ( this.#currentSortAlgorithm === "name" ) { this.#sortUnitsByName(); } + if ( this.#currentSortAlgorithm === "unitName" ) { + this.#sortUnitsByUnitName(); + } + Object.values( this.#units ).forEach( ( unit:Unit ) => { @@ -142,6 +146,28 @@ export class UnitListPanel extends Panel { } + #sortUnitsByCoalition() { + + this.#units.sort( ( unit1:Unit, unit2:Unit ) => { + + let str1 = unit1.getCoalition(); + let str2 = unit2.getCoalition(); + + let cmp = this.#sortStringsCompare( str1, str2 ); + + if ( cmp !== 0 ) { + return cmp; + } + + str1 = unit1.getUnitName().toLowerCase(); + str2 = unit2.getUnitName().toLowerCase(); + + return this.#sortStringsCompare( str1, str2 ); + + }); + + } + #sortUnitsByName() { this.#units.sort( ( unit1:Unit, unit2:Unit ) => { diff --git a/client/views/panels/unitlist.ejs b/client/views/panels/unitlist.ejs index 0c0085e3..aa459c4e 100644 --- a/client/views/panels/unitlist.ejs +++ b/client/views/panels/unitlist.ejs @@ -1,10 +1,10 @@ -