Skip to main content

Python sorted dictionary: a Python dictionary in which the keys are always in ascending order

Project description

pysorteddict

Like Python's dict, but the keys are always in ascending order.

Hatch project

style test package

Installation

pysorteddict is available on PyPI for macOS and Linux. It requires Python 3.10 or newer.

pip install pysorteddict

You might be able to install it on Windows by running the above command if you have the Python development headers and libraries installed.

Usage

All keys in a sorted dictionary must be of the same type, which must be passed to the constructor. The values, though, can be of any type.

from pysorteddict import SortedDict

sorted_dict = SortedDict(int)
sorted_dict[5659] = "gaining weight is"
sorted_dict[1992] = 31.692
sorted_dict[24274] = "times easier than"
sorted_dict[9765] = ["losing", "weight"]
print(sorted_dict)

This program should output {1992: 31.692, 5659: 'gaining weight is', 9765: ['losing', 'weight'], 24274: 'times easier than'}. Note that the keys are in ascending order.

Documentation

class pysorteddict.SortedDict(key_type)

Constructor. Create a new sorted dictionary in which the keys are of type key_type. As of the current version, key_type must be int. Support for some more types will be added in due course.

len(d)

Return the number of key-value pairs in a sorted dictionary d.

d[key]

Return the value mapped to key in a sorted dictionary d.

  • If key is not an instance of key_type passed to the constructor, raise TypeError.
  • If key is not present in d, raise KeyError.

d[key] = value

Map value to key in a sorted dictionary d, overwriting the previously-mapped value (if any).

  • If key is not an instance of key_type passed to the constructor, raise TypeError.

del d[key]

Remove key and the value mapped to it from a sorted dictionary d.

  • If key is not present in d, raise KeyError.

str(d)

Return a human-readable representation of a sorted dictionary d.

d.items()

Return the list of key-value pairs in a sorted dictionary d. This list will be sorted.

d.keys()

Return the list of keys in a sorted dictionary d. This list will be sorted.

d.values()

Return the list of values in a sorted dictionary d. The order of the values will be such that the keys they are mapped to will be in ascending order.

Project details


Download files

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

Source Distribution

pysorteddict-0.0.3.tar.gz (40.5 kB view details)

Uploaded Source

Built Distributions

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

pysorteddict-0.0.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (63.7 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

pysorteddict-0.0.3-pp310-pypy310_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (67.0 kB view details)

Uploaded PyPymanylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

pysorteddict-0.0.3-cp313-cp313-musllinux_1_2_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

pysorteddict-0.0.3-cp313-cp313-musllinux_1_2_i686.whl (1.2 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ i686

pysorteddict-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (153.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pysorteddict-0.0.3-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (154.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

pysorteddict-0.0.3-cp313-cp313-macosx_10_13_universal2.whl (46.7 kB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

pysorteddict-0.0.3-cp312-cp312-musllinux_1_2_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pysorteddict-0.0.3-cp312-cp312-musllinux_1_2_i686.whl (1.2 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ i686

pysorteddict-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (153.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pysorteddict-0.0.3-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (154.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

pysorteddict-0.0.3-cp312-cp312-macosx_10_13_universal2.whl (46.7 kB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

pysorteddict-0.0.3-cp311-cp311-musllinux_1_2_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

pysorteddict-0.0.3-cp311-cp311-musllinux_1_2_i686.whl (1.2 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ i686

pysorteddict-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (152.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pysorteddict-0.0.3-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (153.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

pysorteddict-0.0.3-cp311-cp311-macosx_10_9_universal2.whl (46.6 kB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

pysorteddict-0.0.3-cp310-cp310-musllinux_1_2_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

pysorteddict-0.0.3-cp310-cp310-musllinux_1_2_i686.whl (1.2 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ i686

pysorteddict-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (151.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pysorteddict-0.0.3-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (152.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

pysorteddict-0.0.3-cp310-cp310-macosx_10_9_universal2.whl (46.6 kB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file pysorteddict-0.0.3.tar.gz.

File metadata

  • Download URL: pysorteddict-0.0.3.tar.gz
  • Upload date:
  • Size: 40.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pysorteddict-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c23aa261240e970cf3e394f63abd1db818b75707fe27f446f638014e7c4c142f
MD5 7c3b51da0df012eaeb1595c8ad9fb208
BLAKE2b-256 eb8c863908383c2e9011dacd456b1a8c7e6ad18738ed7bc8c312db06eb743010

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aed12568afa37d40651ed379d37abd66c9222640404d3487ab9c06cb72998678
MD5 5301b5b85b8dad9350e54b617eec0f76
BLAKE2b-256 30eb40da7bd2579eec1b2323d4c9cc055c994a6dbb6f1520e757a099b637f347

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-pp310-pypy310_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-pp310-pypy310_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 8ca0d54417a24b260320718f30073128ca08aaba210b63c05be9bcb764d61e79
MD5 87ea024aff87b05af152c3ed41d873c3
BLAKE2b-256 056a6f0c180863f261f1ff1bfb005c0e29056e0f8e42936c42b214e6b7117891

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5acd514ee013eea238386889c464f9926ecdf4ed2df6b278823826f960dc8a86
MD5 56ab24e8e4365d673f933d0b8cbc81b3
BLAKE2b-256 faeeab335f5cf8d5a9690a354646e1584f893458dc3a38cf9387caa61e1e963a

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp313-cp313-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp313-cp313-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 0877f647879a409d65a1221428a825c416efe8beb329a4b5b90e97a429fdfc66
MD5 379590f9ad7837567a9aee0eee9984be
BLAKE2b-256 06990445284636b31457ec878f96c9608a3de3b1b78b1dadc9d5a2c2e915d545

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0feca37118b13bb272e8cf024b30649845c13f4fdfefe3e086fa85c7580a42f7
MD5 6460829f4835e1daf305bf7c0c9a4b30
BLAKE2b-256 103b35cbbf0f56f81eff4e3272dcfd8499f3dc90f955eba0d98f6915db44d86a

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 519da1ed8f9ea47222a49d912415c5f97e73b62f8bdbc765564924ba4d00e504
MD5 4710f5b526abca7a197490f989fac633
BLAKE2b-256 ac9eb4ed8bb2ab37904c3cb510650382574f29cf52fedfd4331a1998cf107a66

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 c60dffb84af2d499c79312dc58e19b1661f21c87503182fdc2d6b65b10071f0d
MD5 a4f9718bf6cbb477ade563267134c04f
BLAKE2b-256 51799cf58536f75985808f085ac9bbac8e9a8e7c41e72ddbad0df91e05728a9f

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fcd526386da28f3739a71c512f1ddd17c128852d6abcc6c9f3fd170984b0797b
MD5 94e56771c18f48d8100f69297fea903a
BLAKE2b-256 ba417bde46aaa3b47f83e0dab7744a2079a68e4b552dbd0741d8a8b877b24723

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp312-cp312-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp312-cp312-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 7aab710ffebb6ad7c165a6ed251c0c9ae584e1b65244b8722be7ed43e3af7d8d
MD5 87f5d76f355f21f3db78e97ee86383d5
BLAKE2b-256 29e27d05f8b9ac6499b4460dcaaa52b852bedb1b3ca164d7c0291997ff1b43d8

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dbc329d4acfaf9ea40cc1bbc9b892d955884057d9d8743bddc599387949559fc
MD5 c487887d989e21793357afb5f7d7ea0f
BLAKE2b-256 b4885a74f7ef6d8000d902863c0edd83d26abd9247452ee4403bd17a433461d9

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 81aec88a13d4534b8bd8e46e0cb0787732da68527874af44cb4fcfc137441b83
MD5 1e091b6b90b8f2a263e347077aeff204
BLAKE2b-256 30ea1a17afa2dd8f8c5c0157883e9b3bdf6442839b60fec7887ebd54eb5f0a67

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 d7179bc67a4e0e8bfc1162729f3e1ce44e768466c93c35849936e6805b45bfc1
MD5 84339397f0311a27c58c1e0574c7985e
BLAKE2b-256 0d826d9ed3b5e9ac16e14775ba055ea7cd99c8c5024a196bda57f7221c2e30b1

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5ae9aeb1053bd2912b505f948c52b8a168a5476e0daa6b843930db0abef2d22c
MD5 ea30fea9e3bee7f15ff7084d3d93555b
BLAKE2b-256 8ae88771899d3463b0b4b5de49ea11d593b058b8970455aea5ed07a6bce503c9

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp311-cp311-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp311-cp311-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 9230d028097a3bfe5f1f89b76ac93fae759cd158f8633975e6946ede5776c876
MD5 8938b360701db3774f949e1824d3bcea
BLAKE2b-256 6023459f9c663d3a8076317883fd70decb950429b1e54e6c65063b8b9b3d601a

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 beb5121d885316b3515fb1c2d354b9b19e88dca11847ed408a94986e57f2c0b3
MD5 c0983536eebc0d84de7b4cb106e557c6
BLAKE2b-256 b1e269fde5f4cdcf1b4872f41932167b29ee1ce0c31e9df5b0f9d746a89bcb76

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 dd2e8abd010d964e485ca0461922066976b04a78d7ff603fb5eb88171219f4c7
MD5 7b60ca9b002b5fcc501bb188960b22ce
BLAKE2b-256 fb9c4d60e28e6495038909f2db87b8f64c0d3e6f191a854ef2ed59c6f238a28b

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 e740e42f0944037137d7133a5737a8b04d1935d9db17ce106f64b3bf37a2c7d3
MD5 5578d2e892eb3d9a6ffbff9d1a07c68f
BLAKE2b-256 36cf26f8e057702709f39950eac7986042368124a7d6ae0dd3e368f320fc5729

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6a39c58c3abaaed48ef242b4e23506cf18b64f93c494bbbec3005c9600ca8293
MD5 bdd5f619b91af34b65f0c34a4b21f3a7
BLAKE2b-256 15b236d6f0a5ab50ddba00f9028a2f2b35862568358056fcff080cf2462435f2

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp310-cp310-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp310-cp310-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 91c5cb4fad6db544b20650889621e2cc79af6e47403bdf6442c54ec13e088e3f
MD5 a2636dbc8d1a5d0eefed965c981a5b6f
BLAKE2b-256 e95aa977ec7b5d20b130a165851fc9e057539f7d967a8b2f702253d51bc606b1

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 de12a41196161edf8f52ef2e9929e6c9823a4d199879b2ca2ef2e6ad0b6f2838
MD5 ad7726452b9410d8b9f495632cb68fd0
BLAKE2b-256 c294b7ce72edde04400a0f97b150e2a5a766ef88061edc28ad2e4b83ae48aa81

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 34fa7eb5ee42a39f5b6c4833d276e215713b8bb9f4d93c27a8c6c7181031ece8
MD5 68920cf03358f0e5d4d9428897baade0
BLAKE2b-256 3df253906b903545948a0f02e691a63db3e6f013d603697fceaad31ad88a66da

See more details on using hashes here.

File details

Details for the file pysorteddict-0.0.3-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pysorteddict-0.0.3-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 1477ad19746f7c4d5b184606d68eb44140d4dadb7c7c8d552b44629566924753
MD5 9401bb36c6cb9292b087a1b539deb8e5
BLAKE2b-256 af28048c4b030eb0ece30b5dfcdef9aed52d892f4d1df9f6bbee9aaa8efad2b8

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