Vocabulary
sorting.slots

Inputs
seqa sequence
sort-specsa sequence of accessors ending with a comparator


Outputs
seq'a sequence


Word description
Sorts a sequence of tuples by the sort-specs in sort-spec. A sort-spec is a sequence of slot accessors ending in a comparator.

Examples
Sort by slot a, then b descending:
USING: accessors math.order prettyprint sorting.slots ; IN: scratchpad TUPLE: sort-me a b ; { T{ sort-me f 2 3 } T{ sort-me f 3 2 } T{ sort-me f 4 3 } T{ sort-me f 2 1 } } { { a>> <=> } { b>> >=< } } sort-by .
{ T{ sort-me { a 2 } { b 3 } } T{ sort-me { a 2 } { b 1 } } T{ sort-me { a 3 } { b 2 } } T{ sort-me { a 4 } { b 3 } } }


Definition

: sort-by ( seq sort-specs -- seq' ) [ ] sort-by-with ;