my @hITS; while () { chomp; my ($score, $qID) = ( split /\t/ )[ 0, 9 ]; push @hITS, [ $_, $score, $qID ]; } @hITS = sort { $b->[1] <=> $a->[1] || $a->[2] cmp $b->[2] } @hITS; for (@hITS) { print $_->[0], "\n"; } #### my @hITS; while () { chomp; my %row; @row{qw( score qID )} = ( split /\t/ )[ 0, 9 ]; push @hITS, \%row; } @hITS = sort { $b->{score} <=> $a->{score} || $a->{qID} cmp $b->{qID} } @hITS; for (@hITS) { print "score: $_->{score} qID: $_->{qID}\n"); }