#property copyright "Andrey Anisimov"
#property link "https://www.mql5.com/ru/users/Sommersy/seller"
#property strict
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart() {
uint launch=GetTickCount(); // View the result
//+===============================================================================================================================+
double Mas[]= { 4, 2, 33, 4, 7, 22, 17, 1, 15, 28, 73, 56, 88, 44, 67 }; // Array to sort
//+-----------------------------------------------------------------------------------------------------------------------------+
int sz=ArrayRange(Mas,0); // Number of elements in the specified array dimension
double Temp; // Temporary variable FOR STORING THE VALUE OF THE found
int idx; // Temporary variable FOR STORING THE INDEX OF THE found element
double Edge; // Value of the outermost element of the checked elements
//+-----------------------------------------------------------------------------------------------------------------------------+
while(sz>0) {
int i=0;
Temp=-999999999999999; // To sort in descending order, the 'Temp' value must be positive
while(i<sz) {
if(Mas[i]>Temp) { // To sort in descending order, replace the ' > ' sign with '<'
Temp=Mas[i];
idx=i;
}
i++;
}
Edge=Mas[sz-1]; // We remember the value of the last element to be checked
Mas[sz-1]=Temp; Mas[idx]=Edge; // Swap with the last one
sz--;
}
//+===============================================================================================================================+
uint finish=GetTickCount()-launch;sz=ArrayRange(Mas,0); // View the result
string elem=" "; int i=0; while(i<sz){elem=elem+(string)Mas[i]+", ";i++;} // View the result
Alert(elem+" | Time "+(string)finish+" ms"); // View the result
//+------------------------------------------------------------------+
}
//+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH+
Comments