Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: sort hash after value from hash in hash

by davorg (Chancellor)
on Nov 24, 2006 at 14:46 UTC ( #585887=note: print w/replies, xml ) Need Help??


in reply to sort hash after value from hash in hash

I want to sort this thing after string1

It's not very clear exactly what you want to do. This will sort the hash by the values associated with 'key1' in each sub-hash.

foreach my $key (sort { $hash->{$a}{key1} cmp $hash->{$b}{key1} } keys + %$hash) { ... }
--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^2: sort hash after value from hash in hash
by ocs (Monk) on Nov 24, 2006 at 14:53 UTC
    Fine, thanks, thats doing exactly what I want :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://585887]
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-05-22 02:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?