sort-with ( ... seq quot: ( ... obj1 obj2 -- ... <=> ) -- ... sortedseq ) (original) (raw)
sort-with ( ... seq quot: ( ... obj1 obj2 -- ... <=> ) -- ... sortedseq )
Factor handbook » The language » Collections » Sequence operations » Sorting sequences
Next: | sort ( seq -- sortedseq ) |
---|
Vocabulary
sorting
Inputs
seq | a sequence |
---|---|
quot | a quotation with stack effect ( ... obj1 obj2 -- ... <=> ) |
Outputs
sortedseq | a new sorted sequence |
---|
Word description
Sorts the elements of seq into a new array using a stable sort.
Notes
The algorithm used is the merge sort.
Definition
USING: accessors kernel sorting.private ;
: sort-with
( ... seq quot: ( ... obj1 obj2 -- ... <=> ) -- ... sortedseq )
[ ] dip
[ sort-pairs ] [ sort-loop ] [ drop accum>> underlying>> ]
2tri ; inline