Sortperm with keyword lt = !isless throws BoundsError

not only crashing silently, but you may end up in a loop that seems to never end

sort!(rand(1:10, 10^7),lt= >=)

In any case, it would be preferable to block unmanaged inputs from code.
And, if possible, give reasons for introducing this limitation, which seems artificial in the context of a sorting function.

I also submit this case to tell where this problem came from.

here I wanted to use the sortperm function to sort the values in descending order as requested by the OP.
Instead of rev=true it occurred to me to use the kwarg lt, which has by default isless. I tried isgreater but it wasn’t defined so I thought !isless or (>=)

1 Like