I h开发者_运维百科ave an array of array (2 dimensions):
var myArray = [
["DVD Title 1","label1","releasedate2","details1", 5241.2541],
["DVD Title 1","label3","releasedate1","details1", 8452.654],
["DVD Title 1","label3","releasedate2","details1", 45465.5465],
["DVD Title 1","label2","releasedate1","details1", 451.545],
["DVD Title 1","label1","releasedate1","details1", 7458.6545],
["DVD Title 2","label2","releasedaten","detailsn", 4545.545],
["DVD Title 2","label1","releasedaten","detailsn", 545.545]
];
I want to sort this array, order by ascending, by the 5th field (the float number).
Is it possible?
myArray.sort(function(a,b){
return a[4] - b[4];
});
精彩评论