Consider...
my %addrbook = $*IN.lines.map( { .split(/\s+/, 2) } ); for %addrbook.classify({ .value.substr(0,1).uc }).sort -> $g { say "{$g.key}:"; .say for $g.value.sort( { .value.uc } )\ ».invert».fmt(" %-32s %s"); }
Perl 6 | Cool Perl 6 | #50 |
my %addrbook = $*IN.lines.map( { .split(/\s+/, 2) } ); for %addrbook.classify({ .value.substr(0,1).uc }).sort -> $g { say "{$g.key}:"; .say for $g.value.sort( { .value.uc } )\ ».invert».fmt(" %-32s %s"); }
Copyright © 2010 http://www.pmichaud.com/2010/pres/ |