There is an object like this...
{
2016: {
3 : [
{ field: "content 1" }
{ field: "content 2" }
]
10 : [
{ field: "content 3" }
]
}
2017: {
8 : [
{ field: "content 4" }
]
}
}
...and I need to get access to the subelements in an ascending order. That means I want to process 2016 object first, then 2017 object.
Within that I need to process the month objects also in ascending order.
Iteration like...
for (var year in map) {
if (map.hasOwnProperty(year)) {
console.log(year)
}
}
won't do the job properly.
2016: {year: 2016, ...}then convert the map into an array then sort the array by years