Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: how to put hash key and value in order

by starX (Chaplain)
on Dec 20, 2012 at 02:57 UTC ( #1009676=note: print w/ replies, xml ) Need Help??


in reply to how to put hash key and value in order

You mean something like this?

%coins = ( "Quarter", 25, "Dime", 10, "Nickel", 5 ); foreach my $key (sort keys %coins) { print "$key: $coins{$key}<br />"; }


Comment on Re: how to put hash key and value in order
Download Code
Re^2: how to put hash key and value in order
by muba (Priest) on Dec 20, 2012 at 12:46 UTC

    Yours will sort on keys, but I'm pretty sure the OP wants his hash sorted on values.

      Hence it was phrased in the form of a question: I wasn't sure.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2015-07-06 20:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (83 votes), past polls