John W. Krahn wrote:
>Shiping Wang wrote:
>>
>> Hi,
>
>Hello,
>
>> 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);
>>
>>
Shiping Wang wrote:
>
> Hi,
Hello,
> 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);
>
Hi,
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