Sorting a hash by value
Explanation: Start with the long form
sub value_cmp($a, $b) { $a.value cmp $b.value }; %h.sort( &value_cmp );
Each pair in %h is passed to &value_cmp
continued...Perl 6 | Perl 6 today | #26 |
Explanation: Start with the long form
sub value_cmp($a, $b) { $a.value cmp $b.value }; %h.sort( &value_cmp );
Each pair in %h is passed to &value_cmp
continued...
Copyright © 2009 http://www.pmichaud.com/2009/pres/ |