Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Perl - Sort a multi dimensional hash

by choroba (Bishop)
on Jan 17, 2013 at 02:30 UTC ( #1013680=note: print w/replies, xml ) Need Help??


in reply to Perl - Sort a multi dimensional hash

You cannot sort a hash. You can sort the keys, though:
my %subhash = %{ $hash->{'Key1:Key1_si'} }; my @sorted_keys = sort { $subhash{$a}{keyc} <=> $subhash{$b}{keyc} } keys %subhash; for my $key (@sorted_keys) { print "Key1:Key1_si $key"; print ' ', $subhash{$key}{$_} for sort keys %{ $subhash{$key} }; print "\n"; }
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013680]
help
Chatterbox?
and cookies bake in the oven...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2018-07-16 18:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (346 votes). Check out past polls.

    Notices?