Hong Ling Mu: Hi, I want to sort the Array. but I want to sort except zero (0). Is it possible with ArraySort code ?
You have to create your own sorting function in that case.
Hong Ling Mu: I want to get below. Array[7] = {5,4,3,2,1}
Sort and then remove the zeros.
Not tested, not compiled, just typed.
#define INDEX uint template<typename Ti, typename To> INDEX remove_copy(const Ti& inp[], INDEX iBeg, INDEX iEnd, To& out[], INDEX oBeg, const Ti& value){ for(; iBeg != iEnd; ++iBeg){ if(!(inp[iBeg] == value) ) out[oBeg++] = inp[iBeg]; } return oBeg; } ////////////////////////////////////////////////////////// double Array[]={0,3,0, 2,4,1,5}; ArraySort(Array); // Array = {0,0,1,2,3,4,5} ArrayResize(Array, remove_copy(Array, 0, ArraySize(Array), Array, 0, 0) ); // Array = {1,2,3,4,5} ArrayGetAsSeries(Array, !ArrayGetAsSeries(Array) ); // Array = {5,4,3,2,1}
Not tested, not compiled, just typed.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi, I want to sort the Array.
but I want to sort except zero (0).
Is it possible with ArraySort code ?
I want to get below.
Array[7] = {5,4,3,2,1}