diff --git a/base/deprecated.jl b/base/deprecated.jl index 238fab1ae71b8..b7d6ff7e613f5 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1743,10 +1743,10 @@ end @deprecate IOContext(io::IO, key, value) IOContext(io, key=>value) # issue #22791 -@deprecate_binding select partialsort -@deprecate_binding select! partialsort! -@deprecate_binding selectperm partialsortperm -@deprecate_binding selectperm! partialsortperm! +@deprecate select partialsort +@deprecate select! partialsort! +@deprecate selectperm partialsortperm +@deprecate selectperm! partialsortperm! # END 0.7 deprecations diff --git a/base/sort.jl b/base/sort.jl index 7930f856f2f92..16910be31f2db 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -85,7 +85,12 @@ issorted(itr; function partialsort!(v::AbstractVector, k::Union{Int,OrdinalRange}, o::Ordering) inds = indices(v, 1) sort!(v, first(inds), last(inds), PartialQuickSort(k), o) - v[k] + + if k isa Integer + return v[k] + else + return view(v, k) + end end """ @@ -706,7 +711,12 @@ function partialsortperm!(ix::AbstractVector{<:Integer}, v::AbstractVector, # do partial quicksort sort!(ix, PartialQuickSort(k), Perm(ord(lt, by, rev, order), v)) - return ix[k] + + if k isa Integer + return ix[k] + else + return view(ix, k) + end end ## sortperm: the permutation to sort an array ##