Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

[Perl6] Sort a hash by value

by haoess (Curate)
on Dec 09, 2008 at 19:01 UTC ( #729238=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %nums = (
      four  => 4,
      one   => 1,
    ...
    for %nums.keys.sort: { %nums{$^a} <=> %nums{$^b} } -> $key {
        say "$key {%nums{$key}}";
    }
    
  2. or download this
    one 1
    two 2
    three 3
    four 4
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://729238]
Approved by moritz
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2016-12-05 09:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (75 votes). Check out past polls.