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

Add property in searchsortedfirst docstring #46511

Merged
merged 3 commits into from
Aug 30, 2022
Merged

Conversation

LilithHafner
Copy link
Member

I think this is a pretty common use case and worth addressing specifically in the docstring.

@LilithHafner LilithHafner added the docs This change adds or pertains to documentation label Aug 27, 2022
base/sort.jl Outdated
@@ -333,6 +333,8 @@ Return the index of the first value in `a` greater than or equal to `x`, accordi
specified order. Return `lastindex(a) + 1` if `x` is greater than all values in `a`.
`a` is assumed to be sorted.

This is the last index at which `x` could be `insert!`ed to maintian sorted order.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This is the last index at which `x` could be `insert!`ed to maintian sorted order.
This is the last index at which `x` could be `insert!`ed to maintain sorted order.

Copy link
Member

@KristofferC KristofferC Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the last index at which x could be insert!ed to maintian sorted order.

What am I missing here?

julia> x = [1,2,4,5,5,7];

julia> idx = searchsortedfirst(x, 4)
3

julia> insert!(x, idx+1, 4) # not idx
7-element Vector{Int64}:
 1
 2
 4
 4
 5
 5
 7

julia> issorted(x)
true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is I that was missing something.

@KristofferC KristofferC merged commit ca629f3 into master Aug 30, 2022
@KristofferC KristofferC deleted the LilithHafner-patch-3 branch August 30, 2022 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants