Sorting pairs by their swap value

 

Hi

This mql5 code needs to sort the pairs from the market watch and write the sorted list in a file or array. I just need help with the sorting please.

am not sure how to sort the values, please give a hand.

Sort the long pairs decending by their swapL values, then sort the short pairs by their swapS values 

Thanks

  uchar j = SymbolsTotal(true);
  for(uchar i=0; i<j; i++){
    string sym = SymbolName(i, true);
    double swapL = SymbolInfoDouble(sym, SYMBOL_SWAP_LONG);
    double swapS = SymbolInfoDouble(sym, SYMBOL_SWAP_SHORT);
    string swapText;
    if(swapL>0 && swapS<0){
      // good to buy pair
      swapText = DoubleToString(swapL,2) + " " + DoubleToString(swapS,2) + " " + sym;
    } else if (swapL<0 && swapS>0){
      // good to sell pair
      swapText = DoubleToString(swapL,2) + " " + DoubleToString(swapS,2) + " " + sym; 
    } 
    // add the swapText to a sorted array and print it later or write to a file    
  }
 
samjesse:

Hi

This mql5 code needs to sort the pairs from the market watch and write the sorted list in a file or array. I just need help with the sorting please.

am not sure how to sort the values, please give a hand.

Sort the long pairs decending by their swapL values, then sort the short pairs by their swapS values 

Thanks

You could at least show an attempt to code your "sort". Where is your array ?
Reason: