Skip to content

Commit

Permalink
argmin ranges bug: you cannot pass an unsorted array to searchsorted
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Apr 6, 2021
1 parent 58fba2b commit 454fc51
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ function argmin(r::AbstractRange)
elseif step(r) > 0
firstindex(r)
else
first(searchsorted(r, last(r)))
lastindex(r)
end
end

Expand All @@ -720,7 +720,7 @@ function argmax(r::AbstractRange)
if isempty(r)
throw(ArgumentError("range must be non-empty"))
elseif step(r) > 0
first(searchsorted(r, last(r)))
lastindex(r)
else
firstindex(r)
end
Expand Down

0 comments on commit 454fc51

Please sign in to comment.