Selectperm bug or wrong documentation?


I think the behavior of selectperm does not fully match the documentation:
Link to documentation:

If I have the array a = [4,3,2,1] and use selectperm(a,2) I can read this part:

If k is a single index (Integer), an array of the first k indices is returned;

then the expected behavior is: to get [4,3] as a[[4,3]] is [1,2] but regarding this:

Also note that this is equivalent to, but more efficient than, calling

I would suspect to get only a single index (3) which is what selectperm actually does.

Using it without documentation I assumed to get [4,3] but I’m also happy to use selectperm(a,1:2). Anyway the documentation seems to be wrong.


Could you file a GitHub issue about this so it doesn’t get lost?


Sure I would also do a PR if the behavior is as expected and only the docstring should be changed.