Perl 编程/关键字/sort
外观
sortsorts theLISTalphabetically and returns the sorted list value when called from list context. The behaviour is undefined for a call from scalar context.
WithoutBLOCKorSUBNAME, the sort is done in standard string comparison order.SUBNAMEis 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.SUBNAMEcan also be a scalar variable name where its value provides the name of or a reference to the subroutine. Instead of an existing subroutine, theBLOCKcan contain the code as an in-line subroutine without a name.
sort SUBNAME LIST
sort BLOCK LIST
sort LIST