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

Support sort(keys(::Dict)) and sort(values(::Dict)) #56978

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LilithHafner
Copy link
Member

Part of the sorting iterables saga:
#38328
#46104
#51977
#52010
#54494

@LilithHafner LilithHafner added iteration Involves iteration or the iteration protocol sorting Put things in order labels Jan 6, 2025
@nsajko nsajko added the collections Data structures holding multiple items, e.g. sets label Jan 7, 2025
@@ -1739,12 +1739,16 @@ function sort!(v::AbstractVector{T};
end

"""
sort(v::Union{AbstractVector, NTuple}; alg::Base.Sort.Algorithm=Base.Sort.defalg(v), lt=isless, by=identity, rev::Bool=false, order::Base.Order.Ordering=Base.Order.Forward)
sort(v; alg::Base.Sort.Algorithm=Base.Sort.defalg(v), lt=isless, by=identity, rev::Bool=false, order::Base.Order.Ordering=Base.Order.Forward)
sort(v::NTuple; kws...) -> NTuple
Copy link
Contributor

@nsajko nsajko Jan 9, 2025

Choose a reason for hiding this comment

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

Suggested change
sort(v::NTuple; kws...) -> NTuple
sort(v::NTuple; kws...)::NTuple

I prefer :: for declaring the return type, in fact I think the -> may be very confusing when used for this purpose, because:

  • -> is actual Julia syntax for defining functions, with conflicting semantics (defines a function, with args on the LHS and return value on RHS)
  • :: is actual Julia syntax, too, but with semantics as expected
  • not sure, but I think the -> is sometimes used in doc strings to express the returned value, as opposed to the type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
collections Data structures holding multiple items, e.g. sets iteration Involves iteration or the iteration protocol sorting Put things in order
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants