Libraries: Radix sort (The fastest numeric sort)

 

Radix sort (The fastest numeric sort):

Sorts the values of a one-dimensional numeric array in the ascending order. It is 3-10 times faster than any other sorting algorithm.

Author: amrali

 
Great job! The speed advantage drops by a factor of 2.5 when moving from int[] to double[].
 
fxsaber #:
Great job! The speed advantage drops by a factor of 2.5 when moving from int[] to double[].
Still the fastest way you can sort floats. Faster than qsort. 
 
This could be useful to many ;) well done ;) 
 

What is this negativity?! I dont know the reason of bad stars.

If you have any suggestions or improvement please add them to the discussion.

 

Update 10 April 2022

More optimized implementation with a faster speed.

 
amrali #:

Update 10 April 2022

More optimized implementation with a faster speed.

Benchmark.


Faster:

      //--- copy back from temp to arr
    #ifdef __MQL5__
      ArraySwap(arr, temp);
    #else // #ifdef __MQL5__
      ArrayCopy(arr, temp);
    #endif // #ifdef __MQL5__ #else
 
#include <RadixSort.mqh> // https://www.mql5.com/en/code/38763

void OnStart()
{
  int Array[];
  
  RadixSort(Array); // array out of range in 'RadixSort.mqh'
}
 
amrali #:

Thank you! Useful work.

 
fxsaber #:

Benchmark.


Faster:

I have included these two improvements in the published code, as you suggested.

Thank you!

 

Update 26 November 2022

More optimized implementation with a faster speed.

Cleaner code and minor bug fixes. 

Special thanks to fxsaber and Dominik Christian Egert