RadixSort is an internal performance optimization. There’s no extensible API to define radixing on custom types and no public way to opt-in to using it when Julia thinks it’s not the best algorithm for the task at hand.
“How do you use RadixSort in Julia v1.9?”
This will use RadixSort in Julia 1.9:
x = rand(1000)
sort(x)
The reason we need x = rand(1000) instead of x = rand(100) is because RadixSort is not a great algorithm for small inputs and so we don’t use it for small inputs.
How can I tell Julia to use RadixSort even when Julia thinks it’s not the right choice
The only good reason I can think of to do this is if you are investigating sorting performance for sorting-related research (e.g. trying to make Base.sort faster). However, if you insist, it is possible to do this, while depending on Julia internals (i.e. your code may break in a minor release)
Here are a couple ways to do this:
x = rand(100)
@assert v"1.9" <= VERSION < v"1.13"
sort(x, alg=Base.Sort.IEEEFloatOptimization(Base.Sort.ComputeExtrema(Base.Sort.RadixSort())))
# or
x = rand(UInt, 100)
@assert v"1.9" <= VERSION < v"1.13"
Base.Sort.radix_sort!(x, extrema(eachindex(x))..., unsigned(8*Base.elsize(x)), similar(x), 0)