sort
sort
sort SUBNAME LIST
sort BLOCK LIST
sort LIST
In list context, this sorts the LIST and returns the sorted list value. In scalar context, the behaviour of sort()
is undefined.
If SUBNAME or BLOCK is omitted, sort
s in standard string comparison order. If SUBNAME is specified, it gives the name of a subroutine that returns an integer less than, equal to, or greater than 0
, depending on how the elements of the list are to be ordered. (The <=>
and cmp
operators are extremely useful in such routines.) SUBNAME may be a scalar variable name (unsubscripted), in which case the value provides the name of (or a reference to) the actual subroutin