=over
=item sort SUBNAME LIST
X
=item sort BLOCK LIST
=item sort LIST
In list context, this sorts the LIST and returns the sorted list value.
In scalar context, the behaviour of L|/sort SUBNAME LIST> is
undefined.
If SUBNAME or BLOCK is omitted, L|/sort SUBNAME LIST>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 C,
depending on how the elements of the list are to be ordered. (The
C >> and C 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
subroutine to use. In place of a SUBNAME, you can provide a BLOCK as
an anonymous, in-line sort subroutine.
If the subroutine's prototype is C, the elements to be compared are
passed by reference in L|perlvar/@_>, as for a normal subroutine.
This is slower than unprototyped subroutines, where the elements to be
compared are passed into the subroutine as the package global variables
C and C (see example below).
If the subroutine is an XSUB, the elements to be compared are pushed on
to the stack, the way arguments are usually passed to XSUBs. C and
C are not set.
The values to be compared are always passed by reference and should not
be modified.
You also cannot exit out of the sort block or subroutine using any of the
loop control operators described in L or with
L|/goto LABEL>.
When L|locale> (but not C