Open meijeru opened 5 years ago
What does current /compare
with a block!
?
@endo64 It gives an error message, even though block!
is in the typespec.
We can add "TBD" to the /compare
doc string.
sort/compare
with block as a comparator doesn't work on R2 too, and no effect the result on R3, o I can't see the use.
Seems OK in R2 @endo64, but I'm a bit foggy right now.
>> n-blk: [1 2 3 3 2 1 2 3 2]
== [1 2 3 3 2 1 2 3 2]
>> sort/skip/compare n-blk 3 [3]
== [3 2 1 2 3 2 1 2 3]
>> sort/skip/compare n-blk 3 [2]
== [3 2 1 1 2 3 2 3 2]
>> sort/skip/compare n-blk 3 [2 3]
== [3 2 1 1 2 3 2 3 2]
>> sort/skip/compare/reverse n-blk 3 [2 3]
== [2 3 2 1 2 3 3 2 1]
>> n-blks: [[1 2 3][ 3 2 1][2 3 2]]
== [[1 2 3] [3 2 1] [2 3 2]]
>> sort/compare n-blks [3]
== [[3 2 1] [2 3 2] [1 2 3]]
>> sort/compare n-blks [2]
== [[3 2 1] [1 2 3] [2 3 2]]
>> sort/compare n-blks [2 3]
== [[3 2 1] [1 2 3] [2 3 2]]
>> sort/compare/reverse n-blks [2 3]
== [[2 3 2] [1 2 3] [3 2 1]]
It does indeed work in R2, and is useful. I have several applications that use it.
sort
works on blocks representing "records" with the/skip
refinement. It has a/compare
refinement with aninteger!
argument which indicates the position of the component within the record, on which to sort. If one wants to sort on multiple components, in a hierarchical fashion, it would be good to have ablock!
argument to/compare
with the positions of the components on which to sort, in the order of importance -- sort first on this component, and when they are equal, sort on that component, etc.