Skip to content

Instantly share code, notes, and snippets.

@igorburago
igorburago / partsort.c
Last active March 22, 2025 16:19
Fast partial sorting of an array on a subinterval
// Copyright 2024 Igor Burago
// SPDX-License-Identifier: ISC
#include <math.h> // for partition_floyd_rivest()
#include <stddef.h> // ptrdiff_t
#include <stdint.h>
#include <string.h> // memcpy(), memmove(), memset()
// Built-in u128 is not strictly required, but it makes mcg64 simpler and faster.
typedef __uint128_t uint128_t;