# sort

Version:

Sorts the input elements in ascending or descending order.

## 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)

## a

Real or complex scalar or array of any dimension.

## b

Dimension of a across which to sort if a is an array. b can be in a range of 1 to the maximum supported array dimension (32). If you do not specify b, the function sorts the first dimension whose size is not equal to 1.

## order

Direction by which to sort elements. order is a string that accepts the following values.

Name Description
'ascend' (default)

Sorts the elements in ascending order.

'descend'

Sorts the elements in descending order.

## c

Elements of a in ascending or descending order, depending on the value of order. MathScript sorts complex vectors by magnitude and angle, in that order. If a is an array, c returns a sorted by the dimension specified in b. c is an array of the same size as a.

## d

Indexes in a of the elements in c. d is a double array of the same size as a.

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

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported