[ library(fd_global) | The ECLiPSe Libraries | Reference Manual | Alphabetic Index ]
# sorted(?List, ?Sorted, ?Positions)

Sorted is a sorted permutation (described by Positions) of List
*List*
- List of domain variables or integers
*Sorted*
- List of domain variables or integers
*Positions*
- List of domain variables or integers

## Description

Declaratively: Sorted is a sorted permutation of List. Positions
is a list whose elements range from 1 to N (where N is the length
of the lists) indicating the position of each unsorted list
element within the sorted list. The positions are all different.
The three lists are constrained to have the same length.
Operationally: the elements in all three lists are constrained
such that their domains are consistent with the declarative
meaning.

Two of the three arguments can be uninstantiated or partial lists
at call time.

Any input variables which do not already have finite bounds will
be given default bounds of -10000000 to 10000000.

### Modes and Determinism

- sorted(+, ?, ?)
- sorted(?, +, ?)
- sorted(?, ?, +)

## Examples

?- length(Xs,4), Xs::0..100, sorted(Xs,Ys,Ps), Xs = [8,20|_].
Xs = [8, 20, _346{[0..100]}, _359{[0..100]}]
Ys = [_445{[0..8]}, _427{[0..20]}, _537{[8..100]}, _635{[20..100]}]
Ps = [_882{[1..3]}, _895{[2..4]}, _908{[1..4]}, _921{[1..4]}]

## See Also

sorted / 2, ordered / 2