The way I see it, should-wise: issorted
should simply check whether lt
holds for each consecutive pair. sort
should have an output for which issorted
is true, if possible. The default lt
should be <=
. sort([1, 1, 2]; lt=isless)
should error out, because it can’t be done, just like sort([1, im]; lt=isless)
can’t be done.
Implementation wise, the possibility of using arbitrary comparisons means it can’t be entirely specialized on type (like above), and it’s not even guaranteed there is an algorithm, consider lt=(x, y)->false
. But the domain of lt
for sort
is a strict subset of that for issorted
.