**Author(s):** Richard A. O'Keefe. All changes by UPM CLIP Group..

**Version:** 1.9#210 (2003/12/21, 2:12:13 CET)

This module implements some sorting list predicates.

`sort`

)`sort`

)- PREDICATE:
**sort/2:** -
`sort(List1, List2)`

The elements of

`List1`

are sorted into the standard order (see section Comparing terms) and any identical elements are merged, yielding`List2`

. The time and space complexity of this operation is at worst`O(N lg N)`

where`N`

is the length of`List1`

.**Usage:**`sort(+list, ?list)`

*Description:*`List2`

is the sorted list corresponding to`List1`

.*The following properties hold globally:*This predicate is understood natively by CiaoPP. (`basic_props:native/1`

)

- PREDICATE:
**keysort/2:** -
`keysort(List1, List2)`

`List1`

is sorted into order according to the value of the*keys*of its elements, yielding the list`List2`

. No merging takes place. This predicate is*stable*, i.e., if an element`A`

occurs before another element`B`

*with the same key*in the input, then`A`

will occur before`B`

also in the output. The time and space complexity of this operation is at worst`O(N lg N)`

where`N`

is the length of`List1`

.**Usage:**`keysort(+keylist, ?keylist)`

*Description:*`List2`

is the (key-)sorted list corresponding to`List1`

.*The following properties hold globally:*This predicate is understood natively by CiaoPP. (`basic_props:native/1`

)

- REGTYPE:
**keylist/1:** -
**Usage:**`keylist(L)`

*Description:*`L`

is a list of pairs of the form`Key-Value`

.

`sort`

)- REGTYPE:
**keypair/1:** -
**Usage:**`keypair(P)`

*Description:*`P`

is a pair of the form "`K-_`

", where`K`

is considered the*key*.

Go to the first, previous, next, last section, table of contents.