# Module sort [Preloaded]

The predicate sys_distinct/1 will remove duplicates from a list
using a hash set in the current implementation, thus relying only on
equality among the elements. On the other hand the predicate sort/2
will sort a list by using a tree in the current implementation and
also requires comparison among the elements.

Examples:

?- sys_distinct([2,1,3,1], X).

X = [2,1,3]

?- sort([2,1,3,1], X).

X = [1,2,3]

The predicate sys_keygroup/2 will key group a list using a hash
table in the current implementation, thus relying only on equality
among the keys. On the other hand the predicate keysort/2 will key
sort a list by using a tree in the current implementation, thus
also requiring comparison among the keys.

Examples:

?- hash_code(f, R).

R = 102

?- term_hash(f(X), 1, 1000, R).

R = 102

The hash code that is the basis for the removal and grouping predicates can be queried by the predicates hash_code/2. The hash code is recursively computed along the structure of the given term. The hash code that forms the basis of our clause indexing can be queried by the predicates term_hash/[2,4].

The following set predicates are provided:

- sort(L, R): [TC2 8.4.3]

- The predicate sorts the list L and unifies the result with R.
- sys_distinct(L, R):
- The predicate sorts the list L and unifies the result with R.
- keysort(L, R): [TC2 8.4.4]
- The predicate key-sorts the pair list L and unifies the result
with R.
- sys_keygroup(L, R):
- The predicate key-groups the pair list L and unifies the
result with R.
**hash_code(T, H):**
- The predicate succeeds when H unifies with the hash code
of T. The term T need not be ground. The hash will be in
the range from -2147483648 to 2147483647.
**term_hash(T, H):**
**term_hash(T, D, R, H):**
- The predicate succeeds when T is ground and when H unifies
with the hash code of T. The predicate also succeeds when T is
non-ground, the H argument is then simply ignored. The quinary
predicate allows specifying a depth D and a modulus R. A negative
depth D is interpreted as infinity.
**locale_sort(L, R):**
**locale_sort(C, L, R):**
- The predicate local sorts the list L and unifies the result
with R. The ternary predicate allows specifying a locale C.
**locale_keysort(L, R):**
**locale_keysort(C, L, R):**
- The predicate locale key-sorts the pair list L and unifies the
result with R. The ternary predicate allows specifying a locale C.

## Kommentare