Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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