The script contains several sorting methods for sorting of double[] array:
There are 2 functions - ascending (Up) and descending (Dn) sort:
The script has several auxiliary functions:
Sorting algorithms performance:

Fig. 1. Sort algorithms performance
The fastest sort method is Hoar sort (Quick sort), but it's recursive and needs a careful use.
Translated from Russian by MetaQuotes Ltd.
Original code: /ru/code/904
Sampler
The indicator calculates perfect market entry signals, which can be used for neural network training.
Pearson correlation indicator
Pearson correlation indicator shows the correlation between symbols.
EMA_STD_VA
Adaptive Exponentially Smoothed Moving Average, based on StdDev indicator.
EMA_ATR_VA
Advaptive Exponential Moving Average - ATR Volatility Adjusted by Jose Silva.