I have an array of objects called objarray. Each object looks like this:
var object = {
age: "45"
coords: "-37.807997 144.705784"
date: Sun Jul 28 2002 00:00:00 GMT+1000 (EST)
}
(date is a Date object)
I need to push each object into a new array based on the date. I want the end result to look like this:
var dateGroups = [[object, object, object],[object, object], [object, object, object]];
Each array within dateGroups contains objects with the same date.
Is this possible to do with arrays? Previously I generated a new object which contained all the objarray objects grouped by date (dates generated from the data):
var alldates = {
"1991" : [object, object, object],
"1992" : [object, object],
//etc...
}
The above seems like a weird solution in practice though, I only need to be able to access the objects by year: i.e. dateGroups[0] = array of objects from the first year
How would I get the data into something like the dateGroups array? Is there a better way to store this type of data?