Sorting a data vector


Sort

The object sorts one or more numerical data vectors. The sort direction is specified in the property dialog. The numerical data vector to be sorted should be connected to the input variable "Data" and appears in sorted order at the "Data" output variable. If an additional data vector is connected to "Auxiliary", the order of it's elements are changed according to the elements of the "Data" input vector. The output variable "Index" returns the original index position of each data element of the "Data" input vector.

The index vector can be used for changing the order of additional vectors similar to the "Auxiliary" vector: Connect the index output variable of a sort object to the "Index" input variable of another sort object. Now any vector connected to the "Data" input variable of the second sort object is not sorted but the order of elements is changed matching the element order of the vector that has been sorted by the first sort object. This functionality is used for sorting a multi column table on a single column: Connect the column to be sorted on to a sort object and use the "Index" output vector in additional sort objects to change the order of the other columns according to the sorted column.


The Vimms User Manual