Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Script | 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.

Input

  psList_[0] = ExStruct(1.0, D'2025.08.06 10:00');
  psList_[1] = ExStruct(2.0, D'2025.08.04 09:00');
  psList_[2] = ExStruct(3.0, D'2025.08.05 12:00');
  psList_[3] = ExStruct(4.0, D'2025.08.07 14:00');
  psList_[4] = ExStruct(5.0, D'2025.08.03 02:00');

Output

MetaTrader Experts, Indicators, Scripts and Libraries

62366

Best MetaTrader Indicators + Profitable Expert Advisors

RobotFX Team

testing