diff --git a/base/deprecated.jl b/base/deprecated.jl index bfe9877fbbb18..747957e6f1beb 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1633,10 +1633,10 @@ function SymTridiagonal(dv::AbstractVector{T}, ev::AbstractVector{S}) where {T,S end # 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 cf173218e14ab..ede1e1e032bce 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 """ @@ -704,7 +709,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 ##