Reputation: 2785
I have an array with meeting
objects having property utc_start
.
I also have an array with reminder
objects having property utc_datetime
.
After combining them as such:
combined = [];
combined = combined.concat(meetings);
combined = combined.concat(reminders);
Is it possible to sort them? Each by using the different property?
combined.sort((a, b) => {
});
Thanks.
Upvotes: 1
Views: 33
Reputation: 152226
You can try with:
combined.sort((a, b) => {
const utcA = a.utc_start || a.utc_datetime;
const utcB = b.utc_start || b.utc_datetime;
// compare utcA with utcB
});
Upvotes: 4