Array and sorting demo I

Data to sort

Note: This sort requires numbers to sort properly.

Field 1:
Field 2:
Field 3:
Field 4:
Field 5:
Field 6:
Field 7:
Field 8:
Field 9:
Field 10:

The JavaScript code:

function sortme() { var fields = document.getElementsByTagName("INPUT"); var nums = new Array(); for (var i=0; i<fields.length; i++) nums.push(parseFloat(fields[i].value)); for (var i=0; i<nums.length-1; i++) { for (var j=i+1; j<nums.length; j++) { if (nums[i] > nums[j]) { var tmp = nums[i]; nums[i] = nums[j]; nums[j] = tmp; } } } for (var i=0; i<nums.length; i++) fields[i].value=nums[i]; return false; }