Skip to content

make keys(dict) and values(dict) more useful #20678

Closed
@StefanKarpinski

Description

@StefanKarpinski

Currently the very common operation of iterating a Dict's keys in sorted order requires writing the overly verbose sort!(collect(keys(d))). This could be abbreviated to sort(keys(d)) by adding a sort method for KeyIterator, but do we manually add methods for all relevant functions in Base? What about user-defined functions that make sense for general collection-like types? At some point (IIRC) I proposed making KeyIterator and ValueIterator subtypes of AbstractVector, which would make many things "just work". The trouble is that indexing is O(n); however, I believe that something like @JeffBezanson's ordered dict experiment could make indexing O(1).

Metadata

Metadata

Assignees

No one assigned

    Labels

    collectionsData structures holding multiple items, e.g. sets

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions