Well, using sort{$b-$a} @numbers rather than sort{$b<=>$a} @numbers seems to run quite a bit more quickly and produce the desired result:
perl> cmpthese -1, { '<=>' => q[@s1=sort{$b<=>$a} 1..10000], '-' => q[@s2=sort{$b - $a} 1..10000] };; Rate <=> - <=> 33.8/s -- -82% - 183/s 441% --
There are probably good reasons why this shoudln't be done outside of golf though.
In reply to Re^4: sort direction
by BrowserUk
in thread sort direction
by rsiedl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |