Which sorting algorithm should I use?


#1

I am currently writing an algorithm where I have to use sortperm multiple times. After reading about this issue https://github.com/JuliaLang/julia/issues/939#issuecomment-288758163 I realized that there seem to be some problems with the performance of sortperm, and I can therefore perhaps improve the performance of my code by using a suitable sorting algorithm.

In the algorithm that I am writing, I have to sort a quite small vector (length < 10000) where the elements in the vector are Floats that are of the same magnitude and close to each other. I am currently using the default setting in sortperm. But for this particular case, there might be some other sorting algorithm that is preferable?


#2

You could see that between this comment and this comment sortperm! improved from 14.113 μs (3 allocations: 48 bytes) to 212.952 ns (3 allocations: 48 bytes) so what is best could be changed with Julia’s implementations.

Maybe writing some benchmark test function which return best function/algorithm for representative sample of your data would be best solution?


#3

Use radix sort from SortingAlgorithms