ARRAY SORT indexes

 

Hi Guys,

I have a question, and I cant quite find the answer. When I sort an array,for example ascending, do indexes keep or they rearrange?

Thank you in advance !

 
Stanislav Ivanov:

Hi Guys,

I have a question, and I cant quite find the answer. When I sort an array,for example ascending, do indexes keep or they rearrange?

Thank you in advance !

Why don't you try?
Array is a data structure that stores a group of elements where each element is accessed directly by its index.
For fast access, the array is stored as a series in the memory, and so the index of each element is translated to its memory address:

Arr[i]=addr(Arr[0]+i*Len(Arr[0]) -

Sort changes the order of the elements in the memory.
 

And out of interest how can it be done in mql4

Thank you

 
Stanislav Ivanov:

And out of interest how can it be done in mql4

Thank you

ArraySort()
ArraySort - Array Functions - MQL4 Reference
ArraySort - Array Functions - MQL4 Reference
  • docs.mql4.com
//| Script program start function                                    |
Reason: