Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Sorting a hash of hashes

by Utilitarian (Vicar)
on May 15, 2012 at 05:05 UTC ( #970563=note: print w/replies, xml ) Need Help??

in reply to Sorting a hash of hashes

The sort function takes an optional customised sort routine wherin you compare aspects of $a and $b. perldoc -f sort.
my %HoH = ( SUB1 => { Test1 => { value1 => "2300", value2 => "0.01", }, Test2 => { value1 => "5000", value1 => "0.34", }, }, SUB2 => { Test1 => { value1 => "2800", value2 => "0.05", }, }, ); for my $sub_key (sort {$HoH{$a}{Test1}{value1} <=> $HoH{$b}{Test1}{val +ue1} }keys %HoH){ print "$HoH{$sub_key}{Test1}{value1}\n"; }
EDIT: Corrected inline sort routine, original post made pre-coffee and shower :)
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://970563]
[shmem]: Python 2.7.9
[shmem]: but! perl4 doesn't suck.
[LanX]: better try 3
[shmem]: that python stuff is none of my business.
[shmem]: but sometimes I have to debug things implemeted by "the other team" and stick their nose into their dirt.
[shmem]: because it affects "my team"

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2018-03-20 18:33 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (257 votes). Check out past polls.