I am trying convert a map into a sorted array. There are millions of solutions around, all of which result in one of many many many different errors.
I want to sort this:
public midiCcs: Map<string, ControllerInfo> = new Map<string, ControllerInfo>();
into an array of ControllerInfo ordered by ccMsb:
export class ControllerInfo {
public name: string = "unassigned";
public ccMsb: number = 0;
public ccLsb: number = 0;
public max: number = 127;
public min: number = 0;
constructor(jsonObject: any) {
this.name = jsonObject.name;
this.ccMsb = jsonObject.ccMsb;
this.ccLsb = jsonObject.ccLsb;
this.max = jsonObject.max;
this.min = jsonObject.min;
}
public toString = () => {
return `ControllerInfo ${this.name} ${this.min} to ${this.max} ccMsb ${this.ccMsb} ccLsb ${this.ccLsb}`
}
}
Would greatly appreciated a way out of this minefield.
[ ...midiCcs.values() ].sort((a, b) => a.ccMsb - b.ccMsb)-- looks good?