| Did you know ... | Search Documentation: |
| chain->sort |
|function],
unique=[bool]code is a function
object, the return status is interpreted as follows:
smaller
@arg1 must be
before @arg2equal Both elements are equal (neither is
deleted, but their order is undefined).Common code objects to use are the arithmetic comparison objects and messages invoking a string comparison method. Examples:
Sort a chain of integers, lowest first:
send(Chain, sort, @arg1 < @arg2).
Sort a chain of char_array objects, alphabetically lowest first:
send(Chain, sort, ?(@arg1, compare, @arg2)).
If compare code is omitted, the contents of the chain is
sorted on alphabetically on their object<-print_name.
If unique equals @on,
duplicates (i.e. pairs of objects for which
executing the comparison yields equal) will be removed.
Default is not to remove duplicates. See also chain->unique.
NOTE: When sorting with a non-function, the result of comparing two
element is a boolean and cannot express equal.
chain->sort
yields an undefined result if the chain contains two or more element for
which code->forward and
code->forward
yield the same result. This undefined behaviour can include a fatal
error.
<-compare ->smaller ->larger ->sort