# sort (MathScript RT Module Function)

LabVIEW 2012 MathScript RT Module Help

Edition Date: June 2012

Part Number: 373123C-01

»View Product Info Download Help (Windows Only)

Owning Class: basic

Requires: MathScript RT Module

## Syntax

c = sort(a)

c = sort(a, b)

c = sort(a, order)

c = sort(a, b, order)

[c, d] = sort(a)

[c, d] = sort(a, b)

[c, d] = sort(a, order)

[c, d] = sort(a, b, order)

## Description

Sorts the input elements in ascending or descending order.

Examples

## Inputs

Name Description
a Specifies a real or complex vector or matrix.
b Specifies the dimension of a across which to sort if a is a matrix. b is a scalar that accepts the following values.

 1 (default) Sorts the matrix by column. 2 Sorts the matrix by row.
order Specifies the direction by which to sort elements. order is a string that accepts the following values.

 'ascend' (default) Sorts the elements in ascending order. 'descend' Sorts the elements in descending order.

## Outputs

Name Description
c Returns the elements of a in ascending or descending order, depending on the value of order. LabVIEW sorts complex vectors by magnitude and angle, in that order. If a is a matrix, c returns a sorted by column or row, depending on the value of b. c is a vector or matrix of the same size as a.
d Returns the indexes in a of the elements in c. d is an integer vector or matrix of the same size as a.

## Details

The following table lists the support characteristics of this function.

 Supported in the LabVIEW Run-Time Engine Yes Supported on RT targets Yes Suitable for bounded execution times on RT Yes

## Examples

A = [-1+2i, 3, -1-2i, -4]
[C, D] = sort(A)

Not Helpful