Perl Programming/Keywords/sort

The sort keyword
sort sorts the LIST alphabetically and returns the sorted list value when called from list context. The behaviour is undefined for a call from scalar context.

Without BLOCK or SUBNAME, the sort is done in standard string comparison order. SUBNAME is the name of a subroutine that returns an integer less than, equal to, or greater than zero depending on the ordering of the elements in the list. SUBNAME can also be a scalar variable name where its value provides the name of or a reference to the subroutine. Instead of an existing subroutine, the BLOCK can contain the code as an in-line subroutine without a name.