11.3.210 sort/2

Synopsis

sort(+List1, -List2)

Sorts the elements of the list List1 into the ascending standard order, and removes any multiple occurrences of an element. The resulting sorted list is unified with the list List2.

Arguments

List1
list of term, must be a proper list
List2
list of term

Exceptions

instatiation_error
type_error
List1 is not a proper list

Examples

     | ?- sort([a,X,1,a(x),a,a(X)], L).
     L = [X,1,a,a(X),a(x)]

(The time taken to do this is at worst order (N log N) where N is the length of the list.)

See Also

ref-lte-cte-sor.


Send feedback on this subject.