my @sorted_list = map { $_->[0] } sort { $a->[1] cmp $b->[1] or $a->[2] cmp $b->[2] } map { [ $_, (split /\t/)[3,4] ] } @database_in;