Skip to content

Guarantee consistent order of pairs, keys and values in Dicts #28196

Open
@cossio

Description

@cossio

There are multiple ways to iterate a Dict. The functions keys(dict) and values(dict) are guaranteed to return items in a consistent order, as stated in the docs (https://docs.julialang.org/en/latest/base/collections/#Base.keys):

But keys(a) and values(a) both iterate a and return the elements in the same order.

This is of course assuming that the Dict has not been modified in between. However it is not asserted that for (k,v) in dict ... also iterates items in the same order as keys(dict) and values(dict). If this is guaranteed, it should be mentioned in the docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    collectionsData structures holding multiple items, e.g. setsdocsThis change adds or pertains to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions