Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://970563]
help
Chatterbox?
[LanX]: morning
marto waves
[Discipulus]: if you prepend 'good' to this mere part of the day you get a wish..as in good morning LanX
[LanX]: good

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2018-02-20 10:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (268 votes). Check out past polls.

    Notices?