I am working with the following code snippet:
export interface Model{
fields: FieldMap;
}
export interface FieldMap { [key: string]: Field;}
export interface Field { name: string; value?: string; }
My question is, how can I sort the field model by key?
I attempted something like this, but encountered error TS2349:
Cannot invoke an expression whose type lacks a call signature.
.fields.sort((a: any, b: any) => { if (a.key < b.key ){ return -1; }else if(a.key > b.key){ return 1; }else{ return 0; } });