Skip to content

Commit 1d78e1a

Browse files
committed
Fix docstrings for partialsortperm() and partialsortperm!()
partialsort(x, k::Integer), partialsortperm(x, k::Integer) and partialsortperm!(x, k::Integer) all return a single value. Also add missing backticks.
1 parent c773f54 commit 1d78e1a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

base/sort.jl

+5-7
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,10 @@ sort(v::AbstractVector; kws...) = sort!(copymutable(v); kws...)
680680
681681
Return a partial permutation of the vector `v`, according to the order specified by
682682
`by`, `lt` and `rev`, so that `v[output]` returns the first `k` (or range of adjacent values
683-
if `k` is a range) values of a fully sorted version of `v`. If `k` is a single index
684-
(Integer), an array of the first `k` indices is returned; if `k` is a range, an array of
685-
those indices is returned. Note that the handling of integer values for `k` is different
686-
from [`select`](@ref) in that it returns a vector of `k` elements instead of just the `k` th
687-
element. Also note that this is equivalent to, but more efficient than, calling
688-
`sortperm(...)[k]`.
683+
if `k` is a range) values of a fully sorted version of `v`. If `k` is a single index,
684+
that value is returned; if `k` is a range, an array of values at those indices is returned.
685+
686+
Note that this is equivalent to, but more efficient than, calling `sortperm(...)[k]`.
689687
"""
690688
partialsortperm(v::AbstractVector, k::Union{Integer,OrdinalRange}; kwargs...) =
691689
partialsortperm!(similar(Vector{eltype(k)}, indices(v,1)), v, k; kwargs..., initialized=false)
@@ -694,7 +692,7 @@ partialsortperm(v::AbstractVector, k::Union{Integer,OrdinalRange}; kwargs...) =
694692
partialsortperm!(ix, v, k, [alg=<algorithm>,] [by=<transform>,] [lt=<comparison>,] [rev=false,] [initialized=false])
695693
696694
Like [`partialsortperm`](@ref), but accepts a preallocated index vector `ix`. If `initialized` is `false`
697-
(the default), ix is initialized to contain the values `1:length(ix)`.
695+
(the default), `ix` is initialized to contain the values `1:length(ix)`.
698696
"""
699697
function partialsortperm!(ix::AbstractVector{<:Integer}, v::AbstractVector,
700698
k::Union{Int, OrdinalRange};

0 commit comments

Comments
 (0)