Reputation: 5151
I have the following JavaScript array,
var myArr= [{
"key" : "Consumer Discretionary",
"values" :[
[1146369600000, 26.425199957521],
[1138683600000, 27.38478809681],
[1141102800000, 27.371377218208],
[1143781200000, 26.309915460827]
]},
{
"key" : "Consumer Staples",
"values" :[
[1159588800000, 7.2800122043237],
[1141102800000, 7.1187787503354],
[1167541200000, 8.351887016482],
[1146369600000, 8.4156698763993]
]}
];
How can I sort the "values" of "key" Consumer Discretionary and then Consumer Staples in ascending order so it will look like
Consumer Discretionary :-
[1138683600000, 27.38478809681]
[1141102800000, 27.371377218208]
[1143781200000, 26.309915460827]
[1146369600000, 26.425199957521]
Any help on this ? Thanks in advance
Upvotes: 1
Views: 106