[plug] [Perl] sorting arrays based on scalar value - Golf any one?

Carl Gherardi C.Gherardi at curtin.edu.au
Mon Nov 18 10:16:39 WST 2002


Borrowing from Tony

> 
> ---
> sub resort{                    11
> @ARGV=shift;                   12
> open O,">@_";                  13
> print O sort{$b<=>$a}<>        23
> }                              01
> ---                            --
>                                60
> 
> It's golf so we can take a few liberties to trim a few characters.
> 

Assume perl called with -p option

perl -p                        03
sub resort{                    11
open O,">@_[1]";               16
print O sort{$b<=>$a}<>        23
}
                             -----
                               53



More information about the plug mailing list