- or download this
Jeff Goldblum Actor
Mary Heartman Priest
...
How can I sort on Vocation?
- or download this
my @data = ( [ qw(Jeff Goldblum Actor) ],
[ qw(Mary Heartman Priest) ],
[ qw(John Ericsson Mathmetician) ],
[ qw(Tony Cisneros Chef) ], );
- or download this
my @sorted = map { $_->[0] } # Line 4
sort { $a->[1] cmp $b->[1] } # Line 3
map { [ $_, $_->[2] ] } # Line 2
@data; # Line 1
- or download this
my @data = ( [ qw(Jeff Goldblum Actor) ],
[ qw(Mary Heartman Priest) ],
...
for ( @sorted ) {
printf "%s %s - %s\n", @{ $_ };
}
- or download this
fappy@flux[16] perl /tmp/sortit
Jeff Goldblum - Actor
Tony Cisneros - Chef
John Ericsson - Mathmetician
Mary Heartman - Priest