functionsort
Sort vector of strings in alphabetic order
Extends from Modelica.Icons.Function (Icon for functions).
Information
Syntax
stringVector2 = Streams.sort(stringVector1); stringVector2 = Streams.sort(stringVector1, caseSensitive=true);
Description
Function sort(..) sorts a string vector stringVector1 in lexicographical order and returns the result in stringVector2. If the optional argument "caseSensitive" is false, lower and upper case letters are not distinguished.
Example
s1 = {"force", "angle", "pressure"};
s2 = Strings.sort(s1);
-> s2 = {"angle", "force", "pressure"};
It is intended for ASCII, the case-insensitive sort is not guaranteed to work for UTF-8.
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| String[:] | stringVector1 | Vector of strings | |
| Boolean | caseSensitive | true | = false, if lower and upper case are ignored when comparing elements of stringVector1 |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| String[size(stringVector1, 1)] | stringVector2 | stringVector1 sorted in alphabetical order |