I have a standard insertion sort and swap function:
function isort(arr,a) {
for (i=2 ; i <= a ; i++) {
for (j = i ; j > 1 && arr[j - 1] > arr[j] ; j--) {
swap(arr,(j - 1),j)
}
}
}
function swap(array,ind1,ind2) {
sw = array[ind1]
array[ind1] = array[ind2]
array[ind2] = sw
}
The isort function returns this output:
12
13.23
23.12
21 (?)
65.43
Awk's native(?) asort returns this:
12
13.23
21
23.12
65.43
Any ideas?
function isort(arr,a) {
for (i=2 ; i <= a ; i++) {
for (j = i ; j > 1 && arr[j - 1] > arr[j] ; j--) {
swap(arr,(j - 1),j)
}
}
}
function swap(array,ind1,ind2) {
sw = array[ind1]
array[ind1] = array[ind2]
array[ind2] = sw
}
The isort function returns this output:
12
13.23
23.12
21 (?)
65.43
Awk's native(?) asort returns this:
12
13.23
21
23.12
65.43
Any ideas?