# orlp/pdqsort

Pattern-defeating quicksort.

Repository: https://github.com/orlp/pdqsort
Canonical: https://ross.abutalabs.com/products/pdqsort
Language: C++
License: Zlib
License Family: permissive
Last push: 2023-12-06T02:22:11+00:00

## Health v2 (maintenance only)
Score: 32/100 (v2, computed 2026-09-03T02:39:23.370411+00:00)
- activity 0, release rhythm 35, longevity 100
- inputs: {"age_days": 4210, "days_push": 1002, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2504, forks 99 (observed 2026-08-28T04:06:57.096780+00:00)

## What it is
Pattern-defeating quicksort (pdqsort) is a C++ sorting algorithm library that combines quicksort's fast average case with heapsort's fast worst case, achieving linear time on certain input patterns. It is a drop-in replacement for std::sort, available as a header-only library under the zlib license.

## Use cases
- sort arrays faster than std::sort
- replace std::sort with a faster drop-in sorting algorithm
- sort data with many duplicate elements efficiently
- sort nearly-sorted or patterned input in linear time
- use a deterministic unstable sort with n log n worst case
- speed up sorting of arithmetic types with branchless comparisons

## When to choose
- you need a faster replacement for std::sort in C++
- your data often contains patterns like ascending/descending runs or many equal elements
- you want a guaranteed n log n worst case without heapsort's overhead
- you want a small header-only library with no dependencies

## When to avoid
- you need a stable sort
- you are not programming in C++
- you need parallel or external sorting for data larger than memory
- your comparison function is expensive and pattern detection overhead dominates

## Facets
- artifact type: library
- maturity: stable
- function: math, developer-tools
- domain: performance, developer-tools
- platform: cpp, cross-platform
- tags: sorting, quicksort, header-only, drop-in-replacement, introsort, algorithms

## Member repositories
- orlp/pdqsort (main) score 32

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:57.096780+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-30T02:26:45.539528+00:00, confidence not recorded.
  - readme: https://github.com/orlp/pdqsort (fetched 2026-08-28T04:06:57.096780+00:00, sha 3b45ca467861)
- Data as of 2026-08-30T08:39:29.467469+00:00.
