Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link to sort! in the docs of searchsorted* #48449

Merged
merged 3 commits into from
Jan 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ according to the order specified by the `by`, `lt` and `rev` keywords, assuming
is already sorted in that order. Return an empty range located at the insertion point
if `a` does not contain values equal to `x`.

See [`sort!`](@ref) for an explanation of the keyword arguments `by`, `lt` and `rev`.

See also: [`insorted`](@ref), [`searchsortedfirst`](@ref), [`sort`](@ref), [`findall`](@ref).

# Examples
Expand All @@ -313,6 +315,9 @@ julia> searchsorted([1, 2, 4, 5, 5, 7], 9) # no match, insert at end

julia> searchsorted([1, 2, 4, 5, 5, 7], 0) # no match, insert at start
1:0

julia> searchsorted([1=>"one", 2=>"two", 2=>"two", 4=>"four"], 2=>"two", by=first) # compare the keys of the pairs
2:3
```
""" searchsorted

Expand All @@ -325,6 +330,8 @@ specified order. Return `lastindex(a) + 1` if `x` is greater than all values in

`insert!`ing `x` at this index will maintain sorted order.

See [`sort!`](@ref) for an explanation of the keyword arguments `by`, `lt` and `rev`.

See also: [`searchsortedlast`](@ref), [`searchsorted`](@ref), [`findfirst`](@ref).

# Examples
Expand All @@ -343,6 +350,9 @@ julia> searchsortedfirst([1, 2, 4, 5, 5, 7], 9) # no match, insert at end

julia> searchsortedfirst([1, 2, 4, 5, 5, 7], 0) # no match, insert at start
1

julia> searchsortedfirst([1=>"one", 2=>"two", 4=>"four"], 3=>"three", by=first) # Compare the keys of the pairs
3
```
""" searchsortedfirst

Expand All @@ -353,6 +363,8 @@ Return the index of the last value in `a` less than or equal to `x`, according t
specified order. Return `firstindex(a) - 1` if `x` is less than all values in `a`. `a` is
assumed to be sorted.

See [`sort!`](@ref) for an explanation of the keyword arguments `by`, `lt` and `rev`.

# Examples
```jldoctest
julia> searchsortedlast([1, 2, 4, 5, 5, 7], 4) # single match
Expand All @@ -369,6 +381,9 @@ julia> searchsortedlast([1, 2, 4, 5, 5, 7], 9) # no match, insert at end

julia> searchsortedlast([1, 2, 4, 5, 5, 7], 0) # no match, insert at start
0

julia> searchsortedlast([1=>"one", 2=>"two", 4=>"four"], 3=>"three", by=first) # compare the keys of the pairs
2
```
""" searchsortedlast

Expand Down