Zero-copy SIMD sorting for TypedArrays and NumPy arrays across Apple Silicon NEON, AVX2, AVX-512, and SVE. Saturating vector lanes at over 600 Million elements/second.
npm install vector-qsort
pip install vector-qsort
Why Vector Quicksort consistently outperforms scalar comparison pipelines.
Highway compiles vectorized sorting kernels for NEON, AVX2, AVX-512, and SVE. At runtime, CPUID automatically activates the widest available vector registers with zero overhead.
Small slices ($N \le 64$) are sorted entirely within vector registers using Bose-Nelson / Batcher sorting networks. No CPU branch mispredictions and no pipeline flushes.
Partitioning checks 8 to 16 keys simultaneously, generates vector bitmasks, and uses hardware `CompressStore` (or NEON table lookups) to pack elements without scalar branching.
Node-API extracts raw pointers via `napi_get_typedarray_info`, and Python accesses C-contiguous memory via DLPack (`nb::ndarray`). Data is sorted directly in place without copies.
Functional, code-first design in Hemanth HM's signature module style.
import vsort from 'vector-qsort';
const f32 = new Float32Array([3.14, -1.5, 42.0, 0, -100.5, 2.71]);
// In-place SIMD sort
vsort(f32);
// Float32Array [-100.5, -1.5, 0, 2.71, 3.14, 42]
// Descending
vsort(f32, { desc: true });
// Non-mutating copy
const sorted = vsort.sorted(f32);
// Off-thread sorting on libuv worker pool (zero event loop lag)
await vsort.async(new Float32Array(10_000_000));
import numpy as np
import vector_qsort
data = np.array([3.14, -1.5, 42.0, 0.0, -100.5, 2.71], dtype=np.float32)
# In-place SIMD sort (zero memory copy)
vector_qsort.sort(data)
# Descending order
vector_qsort.sort(data, desc=True)
# Non-mutating copy
sorted_data = vector_qsort.sorted(data)