@array = sort { $a->[2] <=> $b->[2] } @array
But, you say you want to find the $i with the smallest z value. It's best to _not_ sort for that:
my $min_i = 0; foreach my $i (1..$#array) { $min_i = $i if $array[$i]->[2] < $array[$min_i]->[2]; }
(update: Oops. Forgot the ->[2].)
This should be signifigantly faster, especially when @array gets large...
In reply to Re: Array sort - kind of...
by wog
in thread Array sort - kind of...
by smitz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |