Skip to content

Instantly share code, notes, and snippets.

@LilithHafner
LilithHafner / radix_sort_mwe.jl
Created October 23, 2021 19:36
[draft 1] A quick & simple radix sort (with benchmarks)
function radix_sort!(vs::AbstractVector{U}, ts::AbstractVector{U},
BinType::Type{<:Unsigned}, bits::Unsigned, chunk_size::Unsigned) where {U <: Unsigned}
axes(vs) == axes(ts) || error("Check failed: axes(vs) == axes(ts)")
bits <= sizeof(U)*8 || error("Check failed: bits <= sizeof(U)")
0 < chunk_size <= bits || error("Check failed: 0 < chunck_size <= bits")
@inbounds begin
counts = Vector{BinType}(undef, 2^chunk_size+1)