I have an object TaskItemVO with field dueDate which has the type Date:
export class TaskItemVO {
public dueDa
If you are running into issues with the accepted answer above. I got it to work by creating a new Date and passing in the date parameter.
private getTime(date?: Date) {
return date != null ? new Date(date).getTime() : 0;
}
public sortByStartDate(array: myobj[]): myobj[] {
return array.sort((a: myobj, b: myobj) => {
return this.getTime(a.startDate) - this.getTime(b.startDate);
});
}