- or download this
@ranked = sort { $a->{FIRST} cmp $b->{FIRST} or $a->{LAST} cmp $b->{LA
+ST} or $a->{AGE} <=> $b->{AGE} } @employees;
- or download this
#!/usr/bin/perl
use strict;
...
foreach my $emp (@ranked) {
print "$emp->{SALARY}\t$emp->{AGE}\t$emp->{FIRST}\t$emp->{LAST}\n"
+;
}
- or download this
$ perl x.pl first age
600000 45 Bill Gates
...
55000 29 Joe Tester
600000 41 Steve Ballmer
600000 45 Bill Gates
- or download this
@types{map -$_, keys %types} = map -$_, values %types;
- or download this
my $sorter = multikeysorter( sub { my $A = $_; map { $A->{s/^-//r} } @
+sort }, @types{@sort} );
- or download this
$ perl5.14.2 x.pl -age last first
600000 45 Bill Gates
600000 41 Steve Ballmer
55000 29 Sally Developer
55000 29 George Tester
55000 29 Joe Tester
- or download this
my $sorter = multikeysorter( sub { my $A = $_; map { (my $k = $_) =~ s
+/^-//; $A->{$k} } @sort }, @types{@sort} );