At 12:26 PM +0800 3/22/12, lina wrote:

%abbrev = (
            'CNS Neurol Disord Drug Targets' => 'CNSNDDT',
            'Intermolecular Forces' => 'IF',
            'Expert Reviews in Molecular Medicine.' => 'ERMM',
            'Nat. Neurosci.' => 'NN',
            'Nat. Rev. Mol. Cell Biol.' => 'NRMCB',
            'Nature Cell Biol.' => 'NCB'
          );

My question is that how can I sort the values. I googled for a while.

sort $abbrev{$a} cmp $abbrev{$b} it complains that:

You need to put the sort test in a block:

for my $key ( sort { $abbrev{$a} cmp $abbrev{$b} } keys %abbrev ) {
  print "key=$key, value=$abbrev{$key}\n";
}



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to