Horje

REVERSE sort - Sorting - Perl
Learn
Perl - Sorting - Reverse sort
Reverse Sort
@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.

Syntax

  • sort SUBNAME LIST
  • sort BLOCK LIST
  • sort LIST
Read Article
https://develop.horje.com/learn/1434/reference