Engee documentation

Sort

Sorting input elements by value.

blockType: Sort

Path in the library:

/Signal Operations/Statistics/Sort

Description

Block Sort ranks the values of the input elements for each channel (column) in ascending or descending order, depending on the value of the Sort order parameter.

Complex input data is sorted by module.

Using the Sort algorithm parameter, you can select a sorting algorithm:

  • Quick sort — uses a recursive sorting method; works faster if you need to sort more than 32 elements.

  • Insertion sort — uses a non-recursive method; works faster if you need to sort less than 32 elements.

The Mode parameter defines the mode of operation of the unit, which you can set to Value, Index or Value and Index.

Ports

Input

Port_1 — data entry
vector | the matrix

The block accepts multichannel input data with a real or complex value. The input data type must be floating-point, integer, or fixed-point, with derivative, equal power of two, and zero offset.

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128

Support for complex numbers: Yes

Output

Val — sorted pass data:q[<br>] vector | the matrix

The unit sorts the data on each channel and outputs the sorted data through this port. The size, data type and complexity of the sorted data correspond to the input data. The block sorts complex numbers modulo.

Dependencies

To use this port, set the Mode parameter Value and Index or Value.

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128

Support for complex numbers: Yes

Idx — indexes of sorted pass data:q[<br>] vector | the matrix

Indexes of sorted data.

Dependencies

To use this port, set the Mode parameter Value and Index or ` Index`.

Data types: UInt32

Parameters

Main

Mode — indicates whether the block returns values, indexes, or both
Value and Index (by default) | Value | Index

When the Mode parameter is set to:

  • Value — the block sorts the elements in each channel of the input matrix M by N in ascending or descending order, depending on the value of the Sort order parameter. Output data at each moment of the sample, , are an M by N matrix that contains sorted columns of input data.

    The block sorts complex numbers modulo.

  • Index — the block sorts the elements in each channel of the input matrix M by N and outputs an array of indices . Each element in represents an integer of the type UInt32, which indexes the sorted value in the corresponding input data column.

  • Value and index — the block displays the sorted values of the input data, , and the corresponding indices in the index array, .

Sort order — sort order
Ascending (by default) | Descending

Specify whether to sort the input data in ascending or descending order.

Sort algorithm — pass sorting method:q[<br>] Quick sort (by default) | Insertion sort

The algorithm Quick sort uses the recursive sorting method and works faster if you need to sort more than 32 elements. The algorithm Insertion sort It uses a non-recursive method and works faster if you need to sort less than 32 elements. When you generate code to avoid recursive function calls, use an algorithm Insertion sort.