Table Of Contents


    Last Modified: December 12, 2016

    Sorts the input elements in ascending or descending order.


    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)



    Real or complex scalar or array of any dimension.


    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.


    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.


    Sorts the elements in descending order.



    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.


    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: DAQExpress does not support FPGA devices

    Recently Viewed Topics