Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2018-11-21 10:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (239 votes). Check out past polls.

    Notices?