perlquestion
haoess
<p>Like in Perl 5 you can print your hash sorted by its values:</p>
<c>my %nums = (
four => 4,
one => 1,
three => 3,
two => 2,
);
for %nums.keys.sort: { %nums{$^a} <=> %nums{$^b} } -> $key {
say "$key {%nums{$key}}";
}</c>
Output (it works with my latest <a href="http://rakudo.org/">Rakudo</a> <a href="http://www.parrot.org/download">checkout</a>):
<c>one 1
two 2
three 3
four 4</c>
<p>Maybe there's a more comfortable (aka <i>shorter</i>) way to get this, without writing <c>%nums</c> three times on the same line?</p>
<p>Thanks, Frank</p>