Keep It Simple, Stupid | |
PerlMonks |
Re^2: Sorting records on a single fieldby salva (Canon) |
on Jan 21, 2010 at 10:40 UTC ( [id://818680]=note: print w/replies, xml ) | Need Help?? |
You can get rid of the reverse operation just inverting the order of the comparison operands. In other words, instead of reverse sort { $a <=> $b } @data use sort { $b <=> $a } @data.
In OP case:
Using reverse also makes the sort operation unstable (entries with equal sorting keys do not keep their relative positions after the sort operation).
In Section
Seekers of Perl Wisdom
|
|