1

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"],
    ];

Test: http://jsfiddle.net/2js5x/

explunit
  • 18,652
  • 6
  • 65
  • 92
Martin
  • 1,947
  • 6
  • 25
  • 44

1 Answers1

1

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...

nicolallias
  • 1,005
  • 2
  • 18
  • 49