Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Sorting a hash by 3 different keys

by jweed (Chaplain)
on Feb 24, 2004 at 01:16 UTC ( #331277=note: print w/replies, xml ) Need Help??


in reply to Sorting a hash by 3 different keys

So you want sorting based on comparison of ITEM1, 2, and 3 in that order? Try:
@sorted = sort { $hash{$a}{ITEM1} <=> $hash{$b}{ITEM1} || $hash{$a}{ITEM2} <=> $hash{$b}{ITEM2} || $hash{$a}{ITEM3} <=> $hash{$b}{ITEM3} } keys %hash;



Code is (almost) always untested.
http://www.justicepoetic.net/

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://331277]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2018-07-23 18:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (472 votes). Check out past polls.

    Notices?