Give the following array of objects, I need to sort them by the date field ascending.
var myArray = [
{
name: \"Joe Blow\",
date: \"Mon Oct 31 2016 00:
If you are trying to use lodash to sort dates in ascending or descending order for your array of objects, you should use _.orderBy
instead of _.sortBy
https://lodash.com/docs/4.17.15#orderBy, this method allows specifying sort orders either by 'asc' or 'desc'
An example would be:
const sortedArray = _(myArray.orderBy([
function(object) {
return new Date(object.date);
}],["desc"])