Hi
I am having problems with the following code. I do not understand how this actually works. I have spent ages going through it. It is used to sort a numeric array as the normal sort would put the array into the following 1,10,12,2. I do not understand the var1 and var2.
function numSort(var1,var2) {
return var1-var2;
}
array1 = new Array(1,2,10,12);
array2 = array1.sort(numSort);
Any help appreciated.
Thank you
I am having problems with the following code. I do not understand how this actually works. I have spent ages going through it. It is used to sort a numeric array as the normal sort would put the array into the following 1,10,12,2. I do not understand the var1 and var2.
function numSort(var1,var2) {
return var1-var2;
}
array1 = new Array(1,2,10,12);
array2 = array1.sort(numSort);
Any help appreciated.
Thank you