Example of sorting structure array in ascending order of fields - MetaTrader 5 script | Trading script download - MT4/MT5 resources

Here is an example of sorting a list of structures by field in ascending order. You can understand and customize the above algorithm according to the purpose of use. This is the most basic example and a direction for solving the arrangement in the array structure.
The algorithms used in this example are quick sort and merge sort.
ps list_[ 0 ] = ExStruct( 1.0 ,D '2025.08.06 10:00' ); ps list_[ 1 ] = ExStruct( 2.0 ,D '2025.08.04 09:00' ); ps list_[ 2 ] = ExStruct( 3.0 ,D '2025.08.05 12:00' ); ps list_[ 3 ] = ExStruct( 4.0 ,D '2025.08.07 14:00' ); ps list_[ 4 ] = ExStruct( 5.0 ,D '2025.08.03 02:00' );
output

Attachment download
📎 structsort.mq5 (3.68 KB)
Source: MQL5 #62366
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •