Sort (FPScript)
Sorts a data set or provides a sort index to a data set.
Syntax
Sort(DataSet [ , Operation = SORT_Y + SORT_INDEX ])
The syntax of the Sort function consists of the following parts:
Part |
Description |
||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DataSet |
The data set to be sorted. All data structures are allowed, except scalar value und list. Supported data types are 16-bit integer, 32-bit integer, 64-bit integer, 32-bit floating point, 64-bit floating point, string, calendar time und time span. If the argument is a list, then the function is executed for each element of the list and the result is also a list. |
||||||||||||||||||||
Operation |
Controls the output and, for signals, selects the component according to which the sorting is to take place. The argument Operation can have the following values:
...plus one or more optional constants.
If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated. If this argument is omitted, it will be set to the default value SORT_Y + SORT_INDEX. |
Remarks
For signals, signal series and space curves, the component can be specified according to which the sorting is to take place. Use the SORT_INDEX option if you would like to use a data set as a sorting criterion for one or more additional data sets. You can use the index data set that you obtain as a result as an argument for the Index Operator to re-sort other data sets. If you do not use SORT_INDEX, then the result has the same structure and unit as the argument DataSet.
Void values are always placed at the end of the resulting series, regardless of whether sorting is ascending or descending.
Available in
FlexPro Basic, Professional, Developer Suite
Examples
Sort({1, 7, 5, 2}) |
Results in {0L, 3L, 2L, 1L}. This is the data series with the sorted indices. |
Sort({1, 7, 5, 2}, SORT_Y) |
Results in {1, 2, 5, 7}. This is the data series with the sorted values. |
Sort({1, 7, 5, 2}, SORT_Y + SORT_DESCENDING) |
Results in {7, 5, 2, 1}. This is the data series with the values sorted in descending order. |
Sort({1, 5, ?, ?, 4, 2}, SORT_Y) |
Results in {1, 2, 4, 5, ?, ?}. Void values are always sorted at the end of the resulting series. |
Sort({1, 5, ?, ?, 4, 2}, SORT_Y + SORT_DESCENDING) |
Results in {5, 4, 2, 1, ?, ?}. This also applies when sorting in descending order. |
Sort(Signal, SORT_X) |
Re-sorts a signal so that the X component is increasing. |
Sort({"D", "c", "B", "a"}, SORT_CASE_SENSITIVE) |
Results in {"B", "D", "a", "c"}. Sorts strings with case sensitivity. |
Sort({"D", "c", "B", "a"}, SORT_IGNORE_CASE) |
Results in {"a", "B", "c", "D"}. Sorts strings, ignoring case sensitivity. |
Sort({"ä", "D", "Ä", "c", "B", "a"}, SORT_COLLATE) |
Results in {"a", "Ä", "ä", "B", "c", "D"}. Sorts strings alphabetically. |
Sort({"Signal1", "Signal11", "Signal2"}, SORT_ALPHANUMERIC) |
Results in {"Signal1", "Signal2", "Signal11"}. Sorts strings alphanumerically. |
Sort({"b1", "ä2", "ä11", "a1", "b2", "b11", "a11", "ä1", "a2"}, SORT_ALPHANUMERIC + SORT_COLLATE) |
Results in {"a1", "a2", "a11", "ä1", "ä2", "ä11", "b1", "b2", "b11"}. Sorts strings alphanumerically in ascending order. |