
msort(+List1, ?List2)

   Succeeds if List2 has the same elements as List1 and is sorted.



Arguments
   +List1              List.
   ?List2              List or variable.

Type
   Comparing and Sorting

Description
   List1 is strictly sorted with respect to the term ordering, (without
   removing duplicates in the sense of ==/2) and unified with List2.


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


Note
   msort(L1,L2) is equivalent to sort(0,=<,L1,L2) except that msort/2 keeps
   duplicates whereas sort/2 removes them.




Resatisfiable
      No.

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



Exceptions
     4 --- List1 is not instantiated.
     5 --- List1 is not a list.

Examples
   
Success:
      msort([3,2,1,2,3],[1,2,2,3,3]).
      msort([2,4,6],L).         (gives L=[2,4,6]).
      msort([2,4,6,1,7,3],L).   (gives L=[1,2,3,4,6,7]).

Fail:
      msort([1,5,3,7],[1,3,7,5]).

Error:
      msort(List1,List2).         (Error 4).
      msort("[1]",L).             (Error 5).





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