我有以下的JavaScript數組,排序Multideminsional陣列
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]
]}
];
我如何按升序「鑰匙」可選消費品,然後消費品的「價值」進行排序,以便它看起來就像
消費者可選: -
[1138683600000, 27.38478809681]
[1141102800000, 27.371377218208]
[1143781200000, 26.309915460827]
[1146369600000, 26.425199957521]
對此有何幫助? 在此先感謝
你嘗試過什麼。你知道數組對象的內建'.sort()'方法嗎? – hugomg 2012-07-24 12:06:02