If you are only concerned with what array belongs to a
particular rating (i.e., you supply the rating and want
to know what sequence it is), then just reverse your logic:
make the rating the key and the array the value.
If you are also concerned with what rating belongs to a
particular sequence however (i.e., you supply the sequence
and want to know it's rating), you will have to rely on
a more complex data structure than an array or a hash.
One example is an array reference that contains array
references that contain the rating as their first element,
and the sequence (as yet another array reference) as the
second element:
my $ref = [
[2, [qw(g a t a c a)]],
[3, [qw(a t a c a g)]],
[1, [qw(t a c a g a)]],
];
And a nasty one liner to print them out (one per line)
ordered by their rating:
print map {join('',@{$_->[1]})."\n"} sort {$a->[0] <=> $b->[0]} @$ref;
jeffa
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
|