Closed
Description
As @rfourquet pointed out here, sort(::Dict)
produces a Vector
of Pair
s. 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?