Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
10
Task/Optional-parameters/Perl/optional-parameters-1.pl
Normal file
10
Task/Optional-parameters/Perl/optional-parameters-1.pl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
sub sorttable
|
||||
{my @table = @{shift()};
|
||||
my %opt =
|
||||
(ordering => sub {$_[0] cmp $_[1]}, column => 0, reverse => 0, @_);
|
||||
my $col = $opt{column};
|
||||
my $func = $opt{ordering};
|
||||
my @result = sort
|
||||
{$func->($a->[$col], $b->[$col])}
|
||||
@table;
|
||||
return ($opt{reverse} ? [reverse @result] : \@result);}
|
||||
Loading…
Add table
Add a link
Reference in a new issue