OK, list here some examples since we are not making any progress here. I'm getting ultra confused 🤯
Thank you for you patience @bugsysha
id | date | time |
1 | 2020-01-22 | 12:00:00 |
2 | 2020-01-20 | 12:00:00 |
3 | 2020-01-20 | 10:00:00 |
With
orderedPaths: function () {
return _.orderBy(this.paths ? this.paths : [], 'date', 'asc');
}
2
3
1
// should be: 3,2,1
With
orderedPaths: function () {
return [...this.paths].sort((a, b) => {
return `${a.date} ${a.time}` - `${b.date} ${b.time}`;
});
}
1
2
3
return [...this.paths].sort((a, b) => {
const aDateTime = `${a.date} ${a.time}`;
const bDateTime = `${b.date} ${b.time}`;
if (aDateTime > bDateTime) {
return 1;
}
if (bDateTime > aDateTime) {
return -1;
}
return 0;
});
WOW, now the order is correct, thank you @bugsysha
You can shorten it, but who cares 🤣
Sorry about the confusion and additional headaches, will next time first display the order, and try to make no typos.
Since you are so nice here you go
return [...this.paths].sort((a, b) => (new Date(`${a.date} ${a.time}`)) - (new Date(`${b.date} ${b.time}`)));
This will get back to 1,2,3. (also sorry about the other thread, would have loved to give you the ba)
This will get back to 1,2,3.
Should work, but like I said who cares.
also sorry about the other thread, would have loved to give you the ba
No problem. For me my suggestion was a cleaner and more expressive approach.
No problem
You are right, actually also using your cleaner method.
Please or to participate in this conversation.