Skip to content

Instantly share code, notes, and snippets.

@igorburago
igorburago / partsort.c
Last active September 15, 2025 15:23
Fast partial sorting of an array on a rank subinterval
// Copyright 2024 Igor Burago. Released under the ISC License.
#include <math.h> // for rank_partition()
#include <stddef.h> // ptrdiff_t
#include <stdint.h>
#include <string.h> // memcpy(), memmove(), memset()
// Built-in u128 is not strictly required, but it makes the Mcg64 RNG simpler.
typedef unsigned __int128 uint128_t;