rsci
11-01-2002, 08:25 PM
Ok stupid number sorting question... I know this is an easy one, its just a Friday thing. How do I sort the array contents by value?
var newA=new Array("23", "2", "2", "1", "10", "16", "8");
newA.sort();
var kt="";
for (i=0; i<newA.length; i++) {
kt+=newA[i]+"\n";
}
alert(kt);
The script sorts the numbers but not by value, only by first digit so the results are:
1 10 16 2 2 23 8
Help?
Thanks,
RSCI
var newA=new Array("23", "2", "2", "1", "10", "16", "8");
newA.sort();
var kt="";
for (i=0; i<newA.length; i++) {
kt+=newA[i]+"\n";
}
alert(kt);
The script sorts the numbers but not by value, only by first digit so the results are:
1 10 16 2 2 23 8
Help?
Thanks,
RSCI