G
GIMME
My question is ... How do I sort an Array on numeric, not character values ?
In the example below, after sorting the contents are 1,10,2,3 .
How do I get the contents to be 1,2,3,10 ?
Thanks,
em
<html>
<head>
<script>
function TestSort() {
var nums = new Array(0);
nums[0] = 1;
nums[1] = 2;
nums[2] = 10;
nums[3] = 3;
nums.sort();
for ( i = 0 ; i < 4 ; i++ ) {
alert(nums);
}
return true;
}
</script>
</head>
<body bgcolor="lightblue">
<input type="button" onclick="TestSort();" value="Click Me">
</body>
</html>
In the example below, after sorting the contents are 1,10,2,3 .
How do I get the contents to be 1,2,3,10 ?
Thanks,
em
<html>
<head>
<script>
function TestSort() {
var nums = new Array(0);
nums[0] = 1;
nums[1] = 2;
nums[2] = 10;
nums[3] = 3;
nums.sort();
for ( i = 0 ; i < 4 ; i++ ) {
alert(nums);
}
return true;
}
</script>
</head>
<body bgcolor="lightblue">
<input type="button" onclick="TestSort();" value="Click Me">
</body>
</html>