I think there are two problems with your code. The more serious one is that you initialize the $index variable to zero after you increment it by calling sorter. Thus, $index will be zero by the time you print the array. The lesser problem is an off-by-one error in the for loop: the halting condition should be $i < $index, as $index points after the last element of the array.
In reply to Re: confusing number of elements in an array
by ambrus
in thread confusing number of elements in an array
by kotoko
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |