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 prolog terms. See compare/3 for this standard ordering.
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]).