通過增加JSON排序有問題。現在它看起來:通過下劃線.sortBy或javascript .sort函數對兩個圖層數組排序
var array = {
"2014\/2015":{
"gamesPlayed":17,"goals":2,"assists":8,"points":10
},
"2013\/2014":{
"gamesPlayed":52,"goals":18,"assists":16,"points":34
},
"2012\/2013":{
"gamesPlayed":39,"goals":12,"assists":15,"points":27
}
};
我需要在今年進行排序項,得到這樣2012/2013對象:{...},2013/2014:{...},2014/2015:{.. } 我嘗試對它進行排序:
var sorted = array.sort(function(a,b){
return a - b;
});
,但它顯示控制檯misstake。
我該怎麼辦? – 2014-10-17 14:46:11
使用真實數組@stress_tn – megawac 2014-10-17 14:53:24