Skip to main content

An ordered dict with sorting capabilities.

Project description

Keep Dict Sorted

This package contains the ODict class, which is an ordered dict with the capability to keep the items sorted not only in insertion order, but in any order that can be achieved by sorting. Typically this can be sorted on the keys or on the values, but a general sort key function is also possible.

Documentation

Just a small example, with items sorted on the values:

from keep_dict_sorted import ODict
D = ODict({'a':0, 'c':1, 'b':3, 'd':2}, sortkey='value')
print(D)  # {'a': 0, 'c': 1, 'd': 2, 'b': 3}
# now change a value:
D['c'] = 4
print(D)  # {'a': 0, 'd': 2, 'b': 3, 'c': 4}

For more: see the docstring of the keep_dict_sorted module and the ODict class.

History

Back in the old times the pyFormex project had its own ordered dict with the capability to sort the items on request. After Python's default dict became ordered, it was dropped from pyFormex as its applications could easily be got with a plane dict and sorting comprehensions. Triggered by a recent discussion on discuss.python.org I grabbed the old source, updated it to Python3, added some more functionality (keeping the items sorted at all times, instead of sorting them on request), and threw the whole thing on PyPi. Enjoy.

License

pyFormex is licensed under the GNU General Public License v3 or later (GPLv3+) and so is this package.

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keep-dict-sorted-1.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keep_dict_sorted-1.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file keep-dict-sorted-1.0.tar.gz.

File metadata

  • Download URL: keep-dict-sorted-1.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for keep-dict-sorted-1.0.tar.gz
Algorithm Hash digest
SHA256 a50a3fb10473a13d6fcf98e99e471f623bb8a188f3a177d0390566c4328617c5
MD5 0baeb971859697431072e3f1152d69f1
BLAKE2b-256 2f917da0ef96fe3bd47329e9626e43448ae9d1dc70190038696490d460deaa77

See more details on using hashes here.

File details

Details for the file keep_dict_sorted-1.0-py3-none-any.whl.

File metadata

  • Download URL: keep_dict_sorted-1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for keep_dict_sorted-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa478c0e47ec7d2f864e3576bf0e84ee4e0ad0ca2409ad8c1b323e2e6d6aec9a
MD5 fd1d517d61651a0d4f846813a1d5b20c
BLAKE2b-256 c412b7ee06d647b7eee2917088980004f294dbaaf390cb085a4677bfa3109e2d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page