Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2018-04-21 08:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?