Re: How do I sort a hash (optionally by value instead of key) by brian d foy- January 6, 2008 This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for details. In article <20080105162917.GA79568genre121.com>, Mark<markgenre121.com> wrote:> printf "%-20s %6dn", $key, $hash$value;> > > Shouldn&39;t that be $hash$key Indeed it should. I&39;ve fixed that in revision 10481.Thanks,http://www.nntp.perl.org/group/perl.perlfaq.workers/2008/01/msg608.html How do I sort a hash (optionally by value instead of key) by Mark- January 5, 2008 The following is given in the FAQ on how to sort a hash... my keys = sort $a cmp $b keys %hash; foreach my $key ( keys ) printf "%-20s %6dn", $key, $hash$value; Shouldn&39;t that be $hash$key Also, I think it would be better to use K&R bracketing insteadof GNU bracketing.Thanks for listening.- Markhttp://www.nntp.perl.org/group/perl.perlfaq.workers/2008/01/msg607.html |