How can I rearrange an array in a specific order based on the order of a hash? Something like this:
my @a = qw(Mary John Dan); print join "\t", @a, "\n";
my %b = ( John => 0, Dan => 1, Mary => 2); print "$_ => $b{$_}\n" for (keys %b);
print "$_-$b{$_}\t" foreach sort {$b{$a} <=> $b{$b}} keys %b;
The final order for @a expect:
John Dan Mary
Thanks,
Shiping
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>