http://qs321.pair.com?node_id=143135


in reply to Array sort - kind of...

@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...