# Sortperm with keyword lt = !isless throws BoundsError

**URL:** <https://discourse.julialang.org/t/sortperm-with-keyword-lt-isless-throws-boundserror/92648>\
**Category:** General Usage\
**Created:** [January 7, 2023, 9:37pm UTC](https://discourse.julialang.org/t/sortperm-with-keyword-lt-isless-throws-boundserror/92648 "2023-01-07T21:37:01Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [January 8, 2023, 11:20am UTC](https://discourse.julialang.org/t/sortperm-with-keyword-lt-isless-throws-boundserror/92648/9 "2023-01-08T11:20:31Z")

</div>

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](https://discourse.julialang.org/t/index-of-max-values-of-n-columns-in-a-dataframe-without-manually-entering-each-column/92532/15) 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 `(>=)`

---

_[View the full topic](https://discourse.julialang.org/t/sortperm-with-keyword-lt-isless-throws-boundserror/92648)._
