Sort 2D array in descending

 

Hi all,

I have a 2D array

double      PTs[][2];

after populating the data, I used arraysort but it is in ascending for the 1st dimension

How can I sort it in descending for the 1st dimension?

Thank you very much 

 
Dua Yong Rew:

Hi all,

I have a 2D array

after populating the data, I used arraysort but it is in ascending for the 1st dimension

How can I sort it in descending for the 1st dimension?

Thank you very much 

Reverse the array after sort , i don't think it has an argument for descending . i think

 
Lorentzos Roussos #:

Reverse the array after sort , i don't think it has an argument for descending . i think

any idea how to reverse it efficiently?

the workaround that I'm using is actually looping it backwards

 
Dua Yong Rew #: any idea how to reverse it efficiently?

Perhaps you should read the manual. ArraySetAsSeries - Array Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

ArraySetAsSeries(PTs, !ArrayGetAsSeries(PTs) );
 
Dua Yong Rew #:

any idea how to reverse it efficiently?

the workaround that I'm using is actually looping it backwards

Your workaround is good , there's also an ArrayReverse function 

 

I did try to do this but I'm getting a weird 

'PTs' - parameter conversion not allowed

 
Lorentzos Roussos #:

Your workaround is good , there's also an ArrayReverse function 

arrayreverse actually works.

thank you very much

 
Dua Yong Rew #:

I did try to do this but I'm getting a weird 

'PTs' - parameter conversion not allowed

double      PTs[][2];
ArraySetAsSeries(PTs, !ArrayGetAsSeries(PTs) );

We can't see your broken code.

Reason: