Scripts: sSortTest

 

sSortTest:

Comparative study of sorting algorithms.

The script contains several sorting methods for sorting of double[] array:

    Sorting algorithms performance:

    • Hoare - 8 ms;
    • Shell - 78 ms;
    • SelectFst - 126 ms;
    • Selection - 582 ms;
    • Insertion - 702 ms;
    • Bubble - 1558 ms;

    Author: Дмитрий

    Fig. 1. Sort algorithms performance

    Fig. 1. Sort algorithms performance

    The fastest sort method is Hoar sort (Quick sort), but it's recursive and needs a careful use.

     

    So far 404 appears. when trying to download or view the script.

     
    experimentally pulled out :)
    Files:
    sSortTest.mq5  24 kb
     

    and I didn't see this standard algorithm:

    void SortUp() 
    {
      int n=ArraySize(arr);
      bool b=true;
      while (b)
      {
        b=false;
        for (int i=1; i<n; i++)
        {
          if (arr[i-1]>arr[i]) { double tmp=arr[i]; arr[i]=arr[i-1]; arr[i-1]=tmp; b=true; }
        }
      }
    }
    
    what is the analogue for it in this lib?
     
    sergeev:

    and I didn't see this standard algorithm:

    what is the analogue for it in this lib?
    So such an algorithm was transformed into a more efficient "bubble", where for each cycle the value of N decreases by 1.
     
    sergeev:

    and I didn't see this standard algorithm:

    what's the analogue for it in this lib?
    There is no analogue. I added it, called it Simple. It's quite slow.
    Files:
     
    1. What place does the standard ArraySort take in the list?
    2. I would like to have in MQL5 a universal standard function for sorting arrays of any type by any condition (as it is done in C++ and similar). Unfortunately, the lack of pointers in MQL5 makes it difficult to write such a function.
     

    Comparison of Hoare and ArraySort

    Files:
     

    It's all together here.

    Files:
     

    Colleagues, I suggest (for future articles) to record video additionally, in my opinion it will be much clearer than reading.

    example


    well, or at least envy the heading interesting programming video, by analogy with interesting financial video... for it will be somehow not rational to put everything in one pile, like this video....