This is my data table
https://i.stack.imgur.com/1DNlj.png in the displayed table, the registration dates are sorted with the oldest date at the top. However, I aim to have the newest data displayed first.
Below is the code snippet I am using:
this.dataSource = [];
this.dataSource = this.dataSource.sort((a, b) => {
if (a.createdAt > b.createdAt) {
return 1;
}
if (a.createdAt < b.createdAt) {
return -1;
}
return 0;
});
The field createdAt
contains string values.