- sort(+List, -Sorted)
-
Succeeds if Sorted can be unified with a list holding the
elements of List, sorted to the standard order of terms (see
section 3.5). Duplicates are removed.
Implemented by translating the input list into a temporary array,
calling the C-library function
qsort(3) using PL_compare()
for comparing the elements, after which the result is translated into
the result list.
- msort(+List, -Sorted)
-
Equivalent to sort/2,
but does not remove duplicates.
- keysort(+List, -Sorted)
-
List is a list of
Key-Value
pairs (e.g. terms of the functor `-
' with
arity 2). keysort/2
sorts List like msort/2,
but only compares the keys. Can be used to sort terms not on standard
order, but on any criterion that can be expressed on a multi-dimensional
scale. Sorting on more than one criterion can be done using terms as
keys, putting the first criterion as argument 1, the second as argument
2, etc. The order of multiple elements that have the same Key
is not changed.
- predsort(+Pred, +List,
-Sorted)
-
Sorts similar to sort/2,
but determines the order of two terms by calling Pred(-Delta,
+E1, +E2) . This call must unify Delta
with one of
<
, const>
or
=
. If built-in predicate compare/3
is used, the result is the same as sort/2.
See also keysort/2. (14)