Scripts: Ascending Sort A Struct Array By A Field Example

 

Ascending Sort A Struct Array By A Field Example:

This is an example of ascending sort a struct list by a field. You can find out and customize the above algorithm depending on the purpose of use, this is the most basic example is also a direction to resolve the arrangement in an array of structure. The algorithm used in this example is Quick Sort and Merge Sort.

Ascending Sort A Struct Array By A Field Example

Author: Le Minh Duc

 
You can't use the built in sort with structs/classes. Instead, you have to use my insertion sort (non-pointer) method. (2016)
          Sort multiple arrays - MQL4 programming forum #9 (2016)
          Array or not to array - Trading Positions - MQL4 programming forum - Page 2 #20.4 (2016)

Or (object pointer) CList method:
          pass generic class data field - Swing Trades - MQL4 programming forum

 
William Roeder #:
You can't use the built in sort with structs/classes. Instead, you have to use my insertion sort (non-pointer) method. (2016)
          Sort multiple arrays - MQL4 programming forum #9 (2016)
          Array or not to array - Trading Positions - MQL4 programming forum - Page 2 #20.4 (2016)

Or (object pointer) CList method:
          pass generic class data field - Swing Trades - MQL4 programming forum

The algorithm I use is Merge Sort and Quick Sort, you can apply it to the way you mentioned