I am working with an array of the following class:
export class Tests {
id: number;
name: string;
createdAt: any;
succress: boolean;
constructor(id: number, name: string, createdAt: any, success: boolean) {
this.id = id;
this.name = name;
this.createdAt = createdAt;
this.succress = success;
}
}
My goal is to sort the array based on the value of the success property (false should be on top and true on bottom). How can I achieve this?
I attempted the following:
this.tests.sort((a,b)=> b.succress - a.succress);
However, this code is not having any effect. Can anyone help me figure out the issue?