Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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."

Comment on Re: Sorting a hash of hashes
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://970563]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2015-11-28 11:44 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (741 votes), past polls