in reply to Re: Reverse sort array
in thread Reverse sort array

Or, if you want to do it without ?: and add a slight touch of obfuscation:

for (sort { "-"x!!$reverse.1*($a cmp $b) } @array) { ... }

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^3: Reverse sort array
by ikegami (Patriarch) on Aug 20, 2009 at 14:40 UTC
    If I wanted to avoid the conditional operator, it would be because I had many options. In that case, I would use a lookup table.
    my $sorter = $lkup{$method}{$direction}; for (sort $sorter @array) { ... }