I have one array of dates, and one array of objects. Each have a date property. I need to cumulatively sort the objects by date. So, for every date in the date array, I would like to create a cumulative object with every object who's date property is previous to the date in the date array.
For example, the following date array and object array:
['2017-11-5', '2018-3-1', '2018-3-22']
[{name: 'Jes', date: '2017-11-2'}, {name: 'Jill', date: '2018-1-5'}, {name: 'Joe', date: '2018-2-25'}, {name: 'Jack', date: '2018-3-21'}]
The desired output would be:
[{name: 'Jes', date: '2017-11-2'}]
[{name: 'Jes', date: '2017-11-2'}, {name: 'Jill', date: '2018-1-5'}, {name: 'Joe', date: '2018-2-25'}]
[{name: 'Jes', date: '2017-11-2'}, {name: 'Jill', date: '2018-1-5'}, {name: 'Joe', date: '2018-2-25'}, {name: 'Jack', date: '2018-3-21'}]
I am trying to do this with approximately 500 dates and 30,000 objects.
Here is a current code snippet, but I am having issues with performance, due to the number of objects I am iterating through.
_.each(dtArray,function(i:Date){
let dt = new Date(i);
let filtered = _.filter(data,function(row){
let dtVal = new Date(row['date']);
return dtVal<=dt;
});
