Value Sorted Dictionary Recipe

class sortedcollections.ValueSortedDict(*args, **kwargs)

Sorted dictionary that maintains (key, value) item pairs sorted by value.

  • ValueSortedDict() -> new empty dictionary.

  • ValueSortedDict(mapping) -> new dictionary initialized from a mapping object’s (key, value) pairs.

  • ValueSortedDict(iterable) -> new dictionary initialized as if via:

    d = ValueSortedDict()
    for k, v in iterable:
        d[k] = v
    
  • ValueSortedDict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example:

    ValueSortedDict(one=1, two=2)
    

An optional key function callable may be specified as the first argument. When so, the callable will be applied to the value of each item pair to determine the comparable for sort order as with Python’s builtin sorted function.

__copy__()

Return shallow copy of the mapping.

__delitem__(key)

del mapping[key]

__setitem__(key, value)

mapping[key] = value

copy()

Return shallow copy of the mapping.