my @sorted = map {$_->[0]} sort { $a->[3] cmp $b->[3] || # sorted ascending alpha on col 3 $b->[2] <=> $a->[2] # then sorted reverse num on col 2 } map {[ $_ ,/(\w+)\s+(\w+)\s+(\w+)/]} ; print for @sorted;