NOTE: Language i am using is Javascript
I have a an array of objects. Each object has three properties: year, date, title. For example:
[
{
year: 2013, date: "23/10/2013", title: "Title1"
},
{
year: 2012, date: "4/2/2012", title: "Title2"
}
]
I need to make an efficient data structure from this array such that:
- All objects with same year are grouped together, and groups are sorted on the basis of "year"
- All objects with same date and title are grouped together. Objects with different dates are sorted.
The data structure should be efficient for reading and traversing (i need to present them in some sort of timeline).