
sort(+List1, ?List2)

   Succeeds if List2 is the strictly ordered, no duplicates version of List1.



Arguments
   +List1              List.
   ?List2              List or variable.

Type
   Comparing and Sorting

Description
   Used to sort the list List1 into the list List2.  sort(List1,List2) is
   equivalent to sort(0,<,List1,List2), duplicates are removed.


   List2 is strictly sorted with respect to the term ordering, removing
   duplicates in the sense of ==/2, and the result is unified with List2.


   The sort is done according to the standard ordering of terms.
   See compare/3 for this standard ordering.




Resatisfiable
      No.

Fail Conditions
      Fails if List2 does not unify with the sorted list version of List1.



Examples
   
Success:
      sort([3,1,6,7,2],S).     (gives S=[1,2,3,6,7]).
      sort([1,3,2,3,4,1],S).   (gives S=[1,2,3,4]).
      sort([f(1,3),h(2,1)],S). (gives S=[f(1,3),h(2,1)]).
      sort(["b",2.0,a(1),1,a],S).
                            (gives S=[2.0,1,"b",a,a(1)]).
Fail:
      sort([2,1,3,4],[2,1,3,4]).





See Also
   compare / 3, msort / 2, sort / 4
