Next: , Previous: , Up: chains   [Index]


35.11 Sorting chains

The following syntactic bindings are exported by the library (vicare containers chains sort). The bindings whose name is prefixed with $ are unsafe operations: they do not validate their arguments before accessing them.

Function: chain-sort-forwards item< chain
Function: $chain-sort-forwards item< chain

Build and return a new chain holding all the objects from chain sorted from the lesser to the greater according to the comparison procedure item<. The objects from chain are the ones in the forwards direction.

item< must be a procedure accepting two objects from chain and returning true if the first argument is less than the second argument.

(let* ((C1 (chain 0 4 3 1 2 5))
       (C2 (chain-sort-forwards < C1)))
  (chain->list C2))
⇒ (0 1 2 3 4 5)