sorted_v = Vectors.sort(v);
(sorted_v, indices) = Vectors.sort(v, ascending=true);


Function sort(..) sorts a Real vector v in ascending order and returns the result in sorted_v. If the optional argument "ascending" is false, the vector is sorted in descending order. In the optional second output argument the indices of the sorted vector with respect to the original vector are given, such that sorted_v = v[indices].


  (v2, i2) := Vectors.sort({-1, 8, 3, 6, 2});
       -> v2 = {-1, 2, 3, 6, 8}
          i2 = {1, 5, 3, 4, 2}


function sortEigenvalue
  extends Modelica.Icons.Function;
  import Modelica_LinearSystems2.Internal.Eigenvalue;
  import Modelica_LinearSystems2.Math.Complex;
  input Eigenvalue ev[:] "Vector to be sorted";
  input Boolean ascending = true "= true if ascending order, otherwise descending order";
  input Boolean sortFrequency = true "True, if sorting is first for imaginary then for real value, otherwise sorting is for absolute value";
  output Eigenvalue sorted_ev[size(ev, 1)] = ev "Sorted vector";
  output Integer indices[size(ev, 1)] = 1:size(ev, 1) "sorted_ev = ev[indices]";
end sortEigenvalue;

Generated at 2020-04-02T01:37:38Z by OpenModelicaOpenModelica 1.16.0~dev-259-g8a5138f using GenerateDoc.mos