PLOGHELP SORT                Jonathan Laventhol, Tuesday 20th March 1984
                                Revised by Kathryn Seifert  October 1986

Predicate for sorting lists

    ?- sort(List, Sorted_list).

Keywords: compare, sort, list


'sort' is a builtin predicate for sorting lists.  It uses the standard
comparison of terms described in PLOGHELP * COMPARE.

For example, to sort a list of numbers:

    ?- sort([5,4,6,3,7], X).
    X = [3, 4, 5, 6, 7] ?
    yes

Note that any identical items will be merged to a single item:

    ?- sort([3,4,3,4,2,11,1,11,1], X).
    X = [1, 2, 3, 4, 11] ?
    yes

Because the standard ordering can compare any two items, we can sort
lists of any kind of object:

    ?- sort([hello, there, jonathan], X).
    X = [hello, jonathan, there] ?
    yes

-- RELATED DOCUMENTATION ----------------------------------------------

PLOGHELP * COMPARE
 Operators to perform metalogical comparisons on Prolog objects

PLOGHELP * KEYSORT
 Predicate for sorting lists of terms with an arity of two
