# Should we make radix sort the primary option for sorting?

**URL:** <https://discourse.julialang.org/t/should-we-make-radix-sort-the-primary-option-for-sorting/112708>\
**Category:** Internals & Design\
**Created:** [April 9, 2024, 5:31am UTC](https://discourse.julialang.org/t/should-we-make-radix-sort-the-primary-option-for-sorting/112708 "2024-04-09T05:31:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tarny\_GG\_Channie](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@Tarny\_GG\_Channie](https://discourse.julialang.org/u/Tarny_GG_Channie)\
**Post date:** [April 9, 2024, 5:31am UTC](https://discourse.julialang.org/t/should-we-make-radix-sort-the-primary-option-for-sorting/112708/1 "2024-04-09T05:31:46Z")

</div>

In a typical programming language, comparison-based sorting function is typically used due to the requirements being simpler, only requiring comparisons.  
In practice, however, if comparisons are possible, radix sorting is also likely possible.  
Because Julia multiple dispatch paradigm allows you to know the type of the sorted objects using generic API, should we take advantage of this fact and leverage the speedup?

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [April 9, 2024, 6:01am UTC](https://discourse.julialang.org/t/should-we-make-radix-sort-the-primary-option-for-sorting/112708/2 "2024-04-09T06:01:58Z")

</div>

Julia’s default sorting is not a simple algorithm but a rather complex pipeline thanks to awesome work by @Lilith 🙂 I highly recommend checking out her JuliaCon 2023 talk about the full sorting pipeline [https://www.youtube.com/watch?v=dXkNazmV9pA](https://www.youtube.com/watch?v=dXkNazmV9pA).

For reference this is what it looks like in my Julia 1.10.2 and if you look closely there is a `RadixSort` in there for a suitable case:

```julia-repl
julia> Base.Sort.DEFAULT_STABLE
Base.Sort.MissingOptimization(
    Base.Sort.BoolOptimization(
        Base.Sort.Small{10}(
            Base.Sort.InsertionSortAlg(),
            Base.Sort.IEEEFloatOptimization(
                Base.Sort.IsUIntMappable(
                    Base.Sort.Small{40}(
                        Base.Sort.InsertionSortAlg(),
                        Base.Sort.CheckSorted(
                            Base.Sort.ComputeExtrema(
                                Base.Sort.ConsiderCountingSort(
                                    Base.Sort.CountingSort(),
                                    Base.Sort.ConsiderRadixSort(
                                        Base.Sort.RadixSort(),
                                        Base.Sort.Small{80}(
                                            Base.Sort.InsertionSortAlg(),
                                            Base.Sort.ScratchQuickSort(missing, missing,
                                                Base.Sort.InsertionSortAlg()))))))),
                    Base.Sort.StableCheckSorted(
                        Base.Sort.ScratchQuickSort(missing, missing,
                            Base.Sort.InsertionSortAlg())))))))

```

---

<div class="post-metadata">

**Author:** ![Tarny\_GG\_Channie](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@Tarny\_GG\_Channie](https://discourse.julialang.org/u/Tarny_GG_Channie)\
**Post date:** [April 9, 2024, 6:19am UTC](https://discourse.julialang.org/t/should-we-make-radix-sort-the-primary-option-for-sorting/112708/3 "2024-04-09T06:19:10Z")

</div>

Oh… Julians seem to always be one step ahead of what I do.
