Skip to content

Sortable iterators makes it harder to make non-breaking feature additions #51977

Closed
@LilithHafner

Description

@LilithHafner

As @rfourquet pointed out here, sort(::Dict) produces a Vector of Pairs. This is because of #46104 which, incidentally, has gone through triage twice already. An OrderedDict could be a better result and changing that after 1.10 is release would be breaking. Specifically, if in 1.13 we decide to add OrderedDict to Base and switched sort(::Dict) to return an OrderedDict that would break push!(sort(d::Dict), p::Pair).

This can be fixed by making sort(::Dict) throw, but then we get to the question of libraries. Adding support for sorting an iterable into a custom type that is not the same as the type of collect(itr) will become a breaking change.

#46104 is in 1.10.

Questions for triage:

  • Should we add another exception to make sort(::Dict) throw?
  • In light of this API design issue which IIRC triage did not explicitly discuss previously, should we revert Support sorting iterators #46104, or let it permanently land?

Metadata

Metadata

Assignees

No one assigned

    Labels

    iterationInvolves iteration or the iteration protocolsortingPut things in ordertriageThis should be discussed on a triage call

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions