Download MetaTrader 5

Sort struct type arrays ?

To add comments, please log in or register
John
80
John  

Hi, is it possible to sort an array of structs ?

Say:

struct profit_targets

{

   string   target_type;   //name of target, "Target 1", "Target 2" 

   double   target_price;  //price of the target

}; 

profit_targets   all_TP[2];

all_TP[0].target_type = "Target 1";

all_TP[0].target_price= 1.35666;

all_TP[1].target_type = "Target 2";

all_TP[1].target_price= 1.34711; 

How can I sort the array all_TP by target_price in Descending Mode ? 

ArraySort(all_TP.target_price,MODE_DESCEND);    does not work  :(

Thanks in advance. 

To add comments, please log in or register