----------------------------------------------------------------------------- Quintus-Prolog: help(sort). ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- The Prolog Language Section g-9-7-2: Sorting Terms Two predicates, sort/2 and keysort/2 sort lists into the standard order. keysort/2 takes a list consisting of key-value pairs and sorts according to the key. Further sorting routines are available in library(samsort). {text} yes | ?- manual(l-3-171). l-3-171 ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- Prolog Reference Pages Section l-3-171: sort/2 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 List2 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.) Exceptions: - instatiation error List1 is not properly instantiated - type error List1 is not a proper list See Also: keysort/2 {manual(g-9-7-2)} -----------------------------------------------------------------------------