in reply to Re: (Ovid) Re: array reference as hash key
in thread array reference as hash key
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:
And a nasty one liner to print them out (one per line) ordered by their rating: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)]], ];
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) 3Re: array reference as hash key
by smgfc (Monk) on Feb 26, 2002 at 05:00 UTC |