请考虑以下代码:
myarray = new Array();
myarray[0] = parseInt("30");
myarray[1] = parseInt("32");
myarray[2] = parseInt("6");
myarray.sort();
document.write (myarray[0] + "," + myarray[1] + "," + myarray[2] + "<br/>");
myarray.reverse();
document.write (myarray[0] + "," + myarray[1] + "," + myarray[2]);
上面的代码将输出如下:
30,32,6
6,32,30
但我想要这样:
6,30,32
32,30,6
我怎样才能做到这一点?请帮忙。提前致谢。