sorted-maphashGBBopen Toolsstable-sortfsortfGoTo Top

sortf   place predicate &key key[Macro]

Purpose
Sort the sequence value of place, and change the value of place to the sorted result.

Package   :gbbopen-tools

Module   :gbbopen-tools

Arguments and values

place     A form which is suitable for use as a generalized reference
predicate     A function designator specifying a function object of two arguments that returns a generalized boolean
key     A function designator specifying a function object of one argument, or nil (default is nil)

Description
The first argument to the predicate function is one element of the sequence value in place (or part of that element extracted by the key function, if supplied); the second argument another element of the sequence (or part of that element extracted by the key function, if supplied). The predicate function should return true if and only if the first argument is strictly less than the second; otherwise the predicate should return false.

The sorting operation can be destructive, and it is not guaranteed stable. Elements considered equal by predicate might not stay in their original order.

See also
    stable-sortf

Example


  > (defparameter *x* '(1 5 3 2 4))
  *x*
  > (sortf *x* '<)
  (1 2 3 4 5)
  > *x*
  (1 2 3 4 5)
  >

The GBBopen Project


sorted-maphashGBBopen Toolsstable-sortfsortfGoTo Top