How can I sort this dataset by its value [1] (4,10,19) so it returns as A,C,B?
var dataset = [
["A","4","570"],
["B","19","123"],
["C","10","395"],
];
How can I sort this dataset by its value [1] (4,10,19) so it returns as A,C,B?
var dataset = [
["A","4","570"],
["B","19","123"],
["C","10","395"],
];
Here you are sir http://jsfiddle.net/2js5x/1/ just using custom sort :)
function on_first(a,b){
return a[1]-b[1];
}
You may evolve the custom sort to do the sum, else...