I have an array where each element in the array (representing a Supreme Court Chief Justice) contains an array of data points (the Chief Justice's name, number of disputes and year).
For each element in the top-level array, I need to sort the lower-level array in ascending order by year.
I attempted to sort year by ascending order using the following:
nested_data.forEach(function(d) {
d.values.sort(d3.ascending(d.values.year));
});
But it did not sort the lower-level array in ascending order by year.
Here is the console.log of my nested data to show its structure.
Array[5]
0:Object
key:"Vinson"
values:Array[7]
0:Object
chief:"Vinson"
disputes:142
year:Tue Jan 01 1946 00:00:00 GMT+0800 (CST)
1:Object
2:Object
3:Object
4:Object
5:Object
6:Object
1:Object
key:"Warren"
values:Array[16]
2:Object
key:"Burger"
values:Array[17]
3:Object
key:"Rehnquist"
values:Array[19]
4:Object
key:"Roberts"
values:Array[11]
How can I sort the lower-level array in ascending order by year?