-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
sort
on AbstractRange
with keywords returns vector
#44858
Comments
The |
Then maybe changing the definitions of sort(r::AbstractUnitRange; rev::Bool=false) = rev ? reverse(r) : r
sort(r::AbstractRange; rev::Bool=false) = issorted(r) ⊻ rev ? r : reverse(r) And similarly for |
Of course that makes the |
This would fix the type instability, but then it doesn't call the generic one when you pass other keyword arguments. sort(r::AbstractUnitRange) = r
function sort(r::AbstractRange; rev::Bool=false)
return ifelse(issorted(r) ⊻ rev, promote(r, reverse(r))...)
end
It seems like the method in |
You would need to add |
I dunno, it seems like when you sort a range it can't, in general, return a range so we return a vector, which is the best that can be done here. I'm very reluctant to do either introduce a type instability or return a different type based on whether there are any keyword args or not. |
As per #9498, adding any keywords to
sort
with anAbstractRange
makes it call theAbstractVector
method and return a vector instead of another range.The text was updated successfully, but these errors were encountered: