@sorted = sort { $b <=> $a } @list;
@sorted = reverse sort { $a <=> $b } @list;
Sorting items in descending order can simply be achieved by swapping $a
and $b
in the comparator block. However, some people prefer the clarity of a separate reverse
even though it is slightly slower.