for my $rec ( sort { $a->[4] <=> $b->[4] } @array ) { ## Now say $rec->[4], $rec->[3], etc. }