sortedcollections
Python Sorted Collections
What it is and what it does
Sorted Collections extends the sortedcontainers library with higher-level data structures that combine sorting with indexed access. It provides ValueSortedDict (dictionary sorted by values), ItemSortedDict (with key-function support), NearestDict (nearest-key lookup), OrderedDict and OrderedSet (with numeric indexing), IndexableDict and IndexableSet (numeric indexing on standard types), and SegmentList (fast random-access insertion/deletion). All implementations are pure Python and built on sortedcontainers.
The package is designed for developers who need sorted collections with efficient indexed access rather than the linear cost of standard Python sorted() calls. It was actively maintained through early 2021 but has since been abandoned, meaning no updates for newer Python versions or bug fixes will be released.
Use it for:
- Build a leaderboard or ranking system where you need to access top entries by score efficiently
- Implement a cache or priority queue where items must be sorted by value and accessed by position
- Create a time-series data structure where you need both chronological order and fast nearest-key lookup
- Store configuration or metadata where insertion order and numeric indexing matter more than hash-based access
- Develop an interval tree or segment-based data structure for range queries with fast insertion/deletion
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides specialized sorted collection data structures (dictionaries, sets, lists) that maintain order and support efficient indexed access and value-based sorting, built on top of sortedcontainers.
Yes, if you need the specific sorted collection types it provides and your codebase targets Python 3.6 through 3.9. No, if you require ongoing maintenance, support for newer Python versions, or active bug fixes—the package is abandoned and has not been updated since 2021-01-18. Consider it stable for legacy codebases but risky for new projects.
Install
sortedcollections on PyPI
pip
pip install sortedcollectionsuv
uv add sortedcollectionspoetry
poetry add sortedcollectionsInstalling sortedcollections
Before you install
Low friction installation with a single pure-Python dependency. However, the package is abandoned—last released in January 2021 and has not been updated since—so expect no maintenance, bug fixes, or compatibility updates.
License in practice
Apache 2.0 permissive license allows free use, modification, and distribution in both open-source and commercial projects with minimal restrictions.
Quickstart
pip install sortedcollections
from sortedcollections import ValueSortedDict
vsd = ValueSortedDict({1: 'a', 2: 'b', 3: 'c'})
print(vsd[0]) # Access by index
Verify before relying
- Whether the package remains compatible with Python versions beyond 3.9 given the January 2021 release cutoff
- Real-world performance characteristics compared to standard dict/set for typical workloads
- Whether sortedcontainers dependency has received updates that might affect behavior or compatibility
Package facts
| License | Apache 2.0 (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — sortedcontainers |
| Maintenance | abandoned — 2,034 days since the last release |
| First released | |
| Downloads | 343,486/month — #7,382 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sortedcollections-2.1.0-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
sortedcontainersProvides sorted list, dict, and set data…
permissive · top 1,000 on PyPI
ordereddictProvides an OrderedDict implementation for…
permissive · top 15,000 on PyPI
ordered-setOrderedSet is a mutable collection that…
permissive · top 1,000 on PyPI
orderly-setProvides multiple ordered set implementations…
permissive · top 1,000 on PyPI
collections-extendedProvides four specialized collection types—bag…
permissive · top 15,000 on PyPI
orderedmultidictorderedmultidict provides a dictionary that…
permissive · top 5,000 on PyPI
fractional-indexingGenerates sortable string keys for inserting…
permissive · top 15,000 on PyPI
sortedcontainers-stubsProvides type stubs for the sortedcontainers…
permissive · top 5,000 on PyPI
pyroaringProvides an efficient, ordered set data…
permissive · top 1,000 on PyPI
multidictMultidict is a dict-like container that allows…
permissive · top 100 on PyPI