# grantjenks/python-sortedcontainers

Python Sorted Container Types: Sorted List, Sorted Dict, and Sorted Set

Repository: https://github.com/grantjenks/python-sortedcontainers
Canonical: https://ross.abutalabs.com/products/python-sortedcontainers
Homepage: http://www.grantjenks.com/docs/sortedcontainers/
Language: Python
License: NOASSERTION
License Family: other
Topics: python, sorted, list, dict, set, data-types
Last push: 2024-03-08T17:47:09+00:00

## Health v2 (maintenance only)
Score: 23/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 0, release rhythm 8, longevity 100
- inputs: {"age_days": 4573, "days_push": 908, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_license
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3975, forks 232 (observed 2026-08-28T04:08:30.925886+00:00)

## What it is
An Apache2-licensed pure-Python library providing sorted collection types: SortedList, SortedDict, and SortedSet. It uses a segmented-list data structure to achieve performance comparable to C extensions without requiring compilation.

## Use cases
- maintain a sorted list with fast insertion and indexing in Python
- implement a priority queue with sorted iteration and membership tests
- build a multiset with efficient min/max lookups
- rank items by their position in a sorted collection
- find nearest neighbors via bisect operations for ML algorithms
- keep a key-value mapping iterated in sorted key order
- store intervals and query overlapping ranges

## When to choose
- you need sorted list, dict, or set semantics in pure Python with no C compiler
- you need fast sorted operations on in-memory datasets up to billions of elements
- you want well-documented, benchmarked, 100% test-covered data structures
- you want lower memory overhead than tree-based implementations

## When to avoid
- your data does not fit in memory and you need an external or disk-backed store
- you need concurrent or thread-safe sorted collections
- a simple sorted() call or heapq suffices for your workload

## Facets
- artifact type: library
- maturity: stable
- function: developer-tools
- domain: developer-tools, data-science
- platform: python, cross-platform
- tags: sorted-containers, sorted-list, sorted-dict, sorted-set, data-structures, pure-python, priority-queue, performance, algorithms

## Member repositories
- grantjenks/python-sortedcontainers (main) score 23

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:08:30.925886+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:24:19.715296+00:00, confidence not recorded.
  - readme: https://github.com/grantjenks/python-sortedcontainers (fetched 2026-08-28T04:08:30.925886+00:00, sha d2c8f2d178a8)
  - homepage: http://www.grantjenks.com/docs/sortedcontainers/ (fetched 2026-08-29T09:18:08.027217+00:00, sha b1a9cee4d8ee)
  - site_page: http://www.grantjenks.com/docs/sortedcontainers (fetched 2026-08-29T09:18:08.036498+00:00, sha b1a9cee4d8ee)
  - site_page: http://www.grantjenks.com/docs/sortedcontainers/implementation.html (fetched 2026-08-29T09:18:08.038354+00:00, sha 24cacdb48471)
  - site_page: http://www.grantjenks.com/docs/sortedcontainers/performance.html (fetched 2026-08-29T09:18:08.040161+00:00, sha 6861c32a5ba2)
  - site_page: http://www.grantjenks.com/docs/sortedcontainers/introduction.html (fetched 2026-08-29T09:18:08.042326+00:00, sha d843fd8edeb1)
  - site_page: http://www.grantjenks.com/docs/sortedcontainers/performance-load.html (fetched 2026-08-29T09:18:08.045568+00:00, sha 6739e78871a1)
  - site_page: http://www.grantjenks.com/docs/sortedcontainers/performance-runtime.html (fetched 2026-08-29T09:18:08.047532+00:00, sha ac9a5f68406e)
  - site_page: http://www.grantjenks.com/docs/sortedcontainers/performance-workload.html (fetched 2026-08-29T09:18:08.049148+00:00, sha d830d5b5247c)
  - site_page: http://www.grantjenks.com/docs/sortedcontainers/performance-scale.html (fetched 2026-08-29T09:18:08.050751+00:00, sha 561156fbed3f)
- Data as of 2026-08-30T08:39:29.467469+00:00.
