(B, I) = sort (A, first, last);
Vector B contains the elements of vector A sorted by increasing values between indices first and last.
Vector I contains the indices of vector A such that I[i] = j means that B[i] = A[j].
First and last are optional. If first is omitted, then first = 1. If last is omitted, then last equals the size of A.
(B, I) = sort
({1.3, 1.2, 7.4, 3.6, 20.9, 0, -6.7, -100, 5, 0.1});
returns
B = { -100, -6.7, 0, 0.1, 1.2, 1.3, 3.6, 5, 7.4, 20.9 };
I = { 8, 7, 6, 2, 1, 4, 9, 3, 5 };
(B, I) = sort({1.3, 1.2, 7.4, 3.6, 20.9, 0, -6.7, -100, 5, 0.1}, 2, 7);
returns
B = { 1.3, 1.2, -6.7, 0, 3.6, 7.4, 20.9, -100, 5, 0.1 };
I = { 1, 2, 7, 6, 4, 3, 5, 8, 9, 10 };
function sort input Real A[:]; input Integer first = 1; input Integer last = size(A, 1); output Real B[size(A, 1)]; output Integer I[size(A, 1)]; end sort;