compare-slots ( obj1 obj2 sort-specs -- <=> )
Sorting by slots
Next:
sort-by ( seq sort-specs -- seq' )
Vocabulary
sorting.slots
Inputs and outputs
obj1
an
object
obj2
an
object
sort-specs
a sequence of accessors ending with a comparator
<=>
+lt+
+eq+
or
+gt+
Word description
Compares two objects using a chain of intrinsic linear orders such that if two objects are
+eq+
, then the next comparator is tried. The comparators are slot-name/comparator pairs.
Definition
USING:
arrays
kernel
math.order
sequences
;
IN:
sorting.slots
:
compare-slots
( obj1 obj2 sort-specs -- <=> )
[
dup
array?
[
unclip-last-slice
[
[
execute-accessor
]
each
]
dip
]
when
execute-comparator
]
with
with
map-find
drop
+eq+
or
;