Introsort/sort_string_array.mq5

31 lines
2.1 KiB
MQL5
Raw Permalink Normal View History

2025-09-19 20:20:20 +00:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| sort_string_array.mq5 |
//| Copyright <EFBFBD> 2018, Amr Ali |
//| https://www.mql5.com/en/users/amrali |
//+------------------------------------------------------------------+
#include "Introsort.mqh"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnStart()
{
string array[25];
//--- Generate random data.
for(int i = 0; i < 25; i++)
{
array[i] = "currency_" + IntegerToString(rand(),5,'0');
}
Introsort(array);
ArrayPrint(array);
}
//+------------------------------------------------------------------+
//--- Uncomment these 2 lines to sort in descending order.
//bool Less(const string left,const string right)
// { return left > right; }