@sortedarry = map { $_ ->[0] } sort { $a->2 <=> $b->2 } sort { $a->[1] cmp $b->[1] } map { my @cols = split /\t/; [$_, $cols[9], $cols[22] ]; } @foo; print "$_\n" foreach @sortedarry;