To do array with object sorting with JavaScript Underscore sortBy, we call sortBy with the array and a callback to return the field to sort by.
For instance, we write
const sorted = _.sortBy(arr, (o) => {
return o.start.dateTime;
});
to call sortBy with arr and a callback that returns the start.dateTime property from the object to sort by this property.
An array with the sorted objects is returned.