Matrix::SortAscend Method

Overload List

#SignatureDescription
1TMtx *SortAscend() const;Sorts the elements in a matrix row(s) in ascending order.
2TMtx *SortAscend(int Col) const;Performs row based sort in ascending order. The Col parameter defines the column based on which the rows are compared with each other.

Overload 1: TMtx *SortAscend() const;

Sorts the elements in a matrix row(s) in ascending order.

Remarks:

Sorts the elements in calling matrix row(s) in ascending order in-place. If the calling matrix is complex, then complex values are first compared by the absolute value and then by the argument.

Note
Wach row is sorted independently from the other.

Examples
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Matrix A;

    A.SetIt(2, 2, false, DewArray<double>{1, 2, 4, 2});
    A.SortAscend();
    // A becomes:
    // [1,2]
    // [2,4]
}
See Also: Matrix::SortDescend
Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler

Overload 2: TMtx *SortAscend(int Col) const;

Performs row based sort in ascending order. The Col parameter defines the column based on which the rows are compared with each other.

#NameTypeDescription
1Colint
Examples
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Matrix A;

    A = {{1, 2}, {4, 2}};
    A.SortAscend();
    // A becomes:
    // [1,2]
    // [2,4]
}
Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler