From 454fc51714c9ba2a5122268fb9405e6f6f4bfc11 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 5 Apr 2021 21:13:58 -0400 Subject: [PATCH] argmin ranges bug: you cannot pass an unsorted array to searchsorted --- base/range.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/range.jl b/base/range.jl index cafa048377851..41120e1bcdaf0 100644 --- a/base/range.jl +++ b/base/range.jl @@ -705,7 +705,7 @@ function argmin(r::AbstractRange) elseif step(r) > 0 firstindex(r) else - first(searchsorted(r, last(r))) + lastindex(r) end end @@ -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