'Sort' is not a member of 'vector' type error

 

Hello Fellow Members

I am trying to sort a simple vector of double values.

                vector close2;
                vector close1;
                // Step [1]: Calculate simple return of Close prices
                close2.CopyRates(gSymbol,gTimeFrame,COPY_RATES_CLOSE,1+gIdx,calWindow); // 1+PrevBar
                close1.CopyRates(gSymbol,gTimeFrame,COPY_RATES_CLOSE,gIdx,calWindow);           // PrevBar (gIdx)

                // In decimal points 0.10 = 10%
                vector simpleReturn = (close1 - close2) / close2;
                
                // Vector::Sort() --> [simpleReturn.Sort();] 'Sort' is not a member of 'vector' type error
                simpleReturn.Sort();

Returns -> 

'Sort' is not a member of 'vector' type error

Search on Forum did not help much.

Please help to resolve.

Regards.

 
Anil Varma:

Hello Fellow Members

I am trying to sort a simple vector of double values.

Returns -> 

Search on Forum did not help much.

Please help to resolve.

Regards.

Old issue, I will try to have more information from MQ.

https://www.mql5.com/en/forum/461379

Mql5 error when use vector::Sort. It is a bug !!!
Mql5 error when use vector::Sort. It is a bug !!!
  • 2024.01.27
  • www.mql5.com
Hello guys, I have a problem when try to use example for vector::Sort at https://www.mql5...
 
Alain Verleyen #:

Old issue, I will try to have more information from MQ.

https://www.mql5.com/en/forum/461379

Thanks Alain

It still seems not implemented along with few other function(s) for matrix & vector.

This is really frustrating to see documentation & tries to use them. And end up with information they are not yet implemented.

@amrali has rightly pointed it out.

 
William Roeder #:
Invalid call. See example Sort - Manipulations - Matrix and Vector Methods - MQL5 Reference

Hi William

Can you please highlight what is wrong in the 'invalid call'

 
Anil Varma #:

Thanks Alain

It still seems not implemented along with few other function(s) for matrix & vector.

This is really frustrating to see documentation & tries to use them. And end up with information they are not yet implemented.

@amrali has rightly pointed it out.

Please don't resurrect old topic. There is nothing more to say for now. Sort() function for vector/matrix is not implemented. You have to use something else.

If I can get more information I will post them.

 
Anil Varma #Can you please highlight what is wrong in the 'invalid call'
                simpleReturn.Sort();
If you clicked on the reference, you would have seen the call requires two parameters.
 
I would like to ask for the ability to derive from built-in types vector, matrix and complex.

Such that we coders/programmers can change, add, overwrite, overload the underlying object. Just like we can with MqlXXX structs.

Would make these types much more useful.
 
Anil Varma:

Hello Fellow Members

I am trying to sort a simple vector of double values.

Returns -> 

Search on Forum did not help much.

Please help to resolve.

Regards.

As a temp solution for this problem (until vector.sort() is added to MQL):

Use: 
void QuickSort(vector &v);


Быстрая сортировка.
Быстрая сортировка.
  • 2021.12.07
  • www.mql5.com
Функции для сортировки массивов. Позволяют сортировать строки и структуры по любому условию.
 
amrali #:
As a temp solution for this problem (until vector.sort() is added to MQL):

Thanks a lot @amrali

Saw reply just now...

How to load class?

#include <QuantNeel\Libraries\Introsoft\QuickSort.mqh>

file 'C:\Users\anilh\AppData\Roaming\MetaQuotes\Terminal\73B7A2420D6397DFF9014A20F1201F97\MQL5\Include\QuantNeel\Libraries\Introsoft\QuickSort.mqh' not found CTSLBackward.mqh 3 11