.CRML.ETL.Utilities.sort

Sorts elements in a vector using the quick sort algorithm

Information

Syntax

(B, I) = sort (A, first, last);

Description

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.

Examples

(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 };

Interface

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;

Generated at 2026-04-01T18:18:38Z by OpenModelicaOpenModelica 1.26.3 using GenerateDoc.mos