Edward Wijaya wrote:
my @AoH = (
{ values => ['AGCGGGGAG','AGCGGGGCG','AGCCGGGCG','AGCCAGGAG'] },
{ values => ['AGCGGAGCG','AGCCGAGGG','AGCGGAGGG'] },
);
for ( 0..$#AoH ) {
$AoH[$_]->{ic} = compute_ic( @{ $AoH[$_]->{values} } );
}
print Dumper @AoH;
Thanks Gunnar,
I managed to construct the Array of Hashes (@AoH) - Glad I did
that! Now, I don't have the clue of how to sort these hashes,
according to IC value and No of elements.
What have you done to find out?
perldoc -f sort
perldoc -q "sort an array"
I think you also need to read up on data structures:
perldoc perldsc
This is one suggestion:
print "Sorted by ic value\n";
for my $hashref ( sort { $a->{ic} <=> $b->{ic} } @AoH ) {
print "$hashref->{ic}: @{ $hashref->{values} }\n";
}
print "\n";
print "Sorted by number of elements\n";
for my $hashref ( sort {
@{ $a->{values} } <=> @{ $b->{values} }
} @AoH ) {
print "$hashref->{ic}: @{ $hashref->{values} }\n";
}
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>