G
Greg Raven
OK, I'm stumped. I want to create a page that allows visitors to enter
torque (dyno) readings at various RPM as a prelude to calculating the
optimum transmission shift points. But, I want to make certain that
the data are in ascending RPM order. The problem is that I can't get
array.sort to work on my rpm/torque/hp matrix.
Here's where I am:
// This works
var dyno = [7000, 2000, 4500, 900];
dyno.sort(function(a, b) {
return a - b;
});
print(dyno);
// This does not work -- no sort effect whatsoever
var dyno = [[7000, 50], [2000, 88], [4500, 109], [900, 77]];
dyno.sort(function(a, b) {
return a - b;
});
print(dyno);
The only thing I found that will work is including a Quicksort routine
in place of the standard (bubble?) sort, but that seems long-winded
and inelegant.
Is there a way of getting array.sort to work on array matrices, and if
so, how?
Thanks.
torque (dyno) readings at various RPM as a prelude to calculating the
optimum transmission shift points. But, I want to make certain that
the data are in ascending RPM order. The problem is that I can't get
array.sort to work on my rpm/torque/hp matrix.
Here's where I am:
// This works
var dyno = [7000, 2000, 4500, 900];
dyno.sort(function(a, b) {
return a - b;
});
print(dyno);
// This does not work -- no sort effect whatsoever
var dyno = [[7000, 50], [2000, 88], [4500, 109], [900, 77]];
dyno.sort(function(a, b) {
return a - b;
});
print(dyno);
The only thing I found that will work is including a Quicksort routine
in place of the standard (bubble?) sort, but that seems long-winded
and inelegant.
Is there a way of getting array.sort to work on array matrices, and if
so, how?
Thanks.