Availability:built-in
[ISO]sort(+List,
-Sorted)True if Sorted can be unified with a list holding the
elements of List, sorted to the standard order of terms (see
section 4.6). Duplicates
are removed. The implementation is in C, using natural merge sort.140Contributed
by Richard O'Keefe. The sort/2
predicate can sort a cyclic list, returning a non-cyclic version with
the same elements.
Note that List may contain non-ground terms. If Sorted
is unbound at call-time, for each consecutive pair of elements in
Sorted, the relation E1 @< E2
will hold.
However, unifying a variable in Sorted may cause this
relation to become invalid,
even unifying a variable in Sorted with another
(older) variable. See also section
4.6.1.