compare ( ... obj1 obj2 quot: ( ... obj -- ... key ) -- ... <=> )
Factor handbook » The language » Objects » Linear order protocol

Prev:>=< ( obj1 obj2 -- >=< )
Next:invert-comparison ( <=> -- >=< )


Vocabulary
math.order

Inputs
obj1an object
obj2an object
quota quotation with stack effect ( ... obj -- ... key )


Outputs
<=>an ordering specifier


Word description
Compares the results of applying the quotation to both objects via <=>.

Notes
The quotation is applied to the first object, then the second. It may update values below its input; computed keys are kept outside that row.

Examples
USING: kernel math.order prettyprint sequences ; "hello" "hi" [ length ] compare .
+gt+


See also
sort, sort-by, inv-sort-by, sort-keys, sort-values

Definition


: compare
( ... obj1 obj2 quot: ( ... obj -- ... key ) -- ... <=> )
bi-curry@ [ call ] dip swap [ call ] dip swap <=> ; inline