skillfed

sortedcollections

Python Sorted Collections

sortedcollections v2.1.0 343.5K downloads/30d#7,382 on PyPI
Permissive license Apache 2.0 Abandoned released

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 sortedcollections

uv

uv add sortedcollections

poetry

poetry add sortedcollections

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseNatural Language :: EnglishProgramming Language :: PythonProgramming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

sorted dictionary with indexingordered set with numeric accessvalue-sorted collectionsindexed sorted data structuresnearest-key lookup dictionarysegment list fast insertionordered collections python
data-structuressorted-collections

More Software Development packages