sort-with ( ... seq quot: ( ... obj1 obj2 -- ... <=> ) -- ... sortedseq )
Factor handbook » The language » Collections » Sequence operations » Sorting sequences

Next:sort ( seq -- sortedseq )


Vocabulary
sorting

Inputs
seqa sequence
quota quotation with stack effect ( ... obj1 obj2 -- ... <=> )


Outputs
sortedseqa 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


: sort-with
( ... seq quot: ( ... obj1 obj2 -- ... <=> ) -- ... sortedseq )
[ <merge> ] dip
[ sort-pairs ] [ sort-loop ] [ drop accum>> underlying>> ]
2tri ; inline