I have two vectors (single row matrices). Assume that we already know the length len.
len
A = [ x1 x2 x3 x4 x5 .... ] B = [ y1 y2 y3 y4 y5 .... ]
[val idx] = sort(sum(abs(Ti-Qi)./(1+Ti+Qi)));
or
[val idx] = sort(sqrt(sum((Ti-Qi).^2)));
Val is the value and idx is the original index value of the column being sorted after applying Euclidean distance. (Matlab Code)