Skip to content

Commit 7a54a2f

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 8150f66 commit 7a54a2f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

base/sort.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,12 @@ 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+
the index in `v` of the value which would be sorted at position `k` is returned;
685+
if `k` is a range, an array with the indices in `v` of the values which would be sorted in
686+
these positions is returned.
687+
688+
Note that this is equivalent to, but more efficient than, calling `sortperm(...)[k]`.
689689
"""
690690
partialsortperm(v::AbstractVector, k::Union{Integer,OrdinalRange}; kwargs...) =
691691
partialsortperm!(similar(Vector{eltype(k)}, indices(v,1)), v, k; kwargs..., initialized=false)
@@ -694,7 +694,7 @@ partialsortperm(v::AbstractVector, k::Union{Integer,OrdinalRange}; kwargs...) =
694694
partialsortperm!(ix, v, k, [alg=<algorithm>,] [by=<transform>,] [lt=<comparison>,] [rev=false,] [initialized=false])
695695
696696
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)`.
697+
(the default), `ix` is initialized to contain the values `1:length(ix)`.
698698
"""
699699
function partialsortperm!(ix::AbstractVector{<:Integer}, v::AbstractVector,
700700
k::Union{Int, OrdinalRange};

0 commit comments

Comments
 (0)