Vector::SortDescend Method

Overload List

#SignatureDescription
1TVec *SortDescend() const;Sorts vector elements in descending order.
2TVec *SortDescend(int Index, int Len) const;Sort calling vector elements [Index]..[Index+Len-1].
3TVec *SortDescend(int Index, int Len, TVecInt *IndexVec) const;Sort calling vector elements [Index]..[Index+Len-1].
4TVec *SortDescend(TVecInt *IndexVec) const;Sort all calling vector elements. IndexVec contains contains the new order of elements.

Overload 1: TVec *SortDescend() const;

Sorts vector elements in descending order.

Remarks:

Sort all calling vector elements in descending order.

Note
If the vector is complex, the complex values are first compared by the absolute value and then by the argument.

Examples
#include "Math387.h"
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Vector a;
    a.SetIt(DewArray<double>{ 1.0, 2.0, 3.0, 4.0 });
    a.SortDescend();
    Vector expected;
    expected.SetIt(DewArray<double>{ 4.0, 3.0, 2.0, 1.0 });
    if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
        throw tException("Vector.SortDescend: mismatch");
}
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Vector a;

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

Overload 2: TVec *SortDescend(int Index, int Len) const;

Sort calling vector elements [Index]..[Index+Len-1].

#NameTypeDescription
1Indexint
2Lenint
Remarks:

An exception is raised if Vector::ConditionCheck is True and array borders are overrun.

Examples
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Vector a;

    a = {2, 1, 3, 4};
    a.SortDescend(); // a = [4,3,2,1]
}
Declared in Dew::Math::Vector · Dew.Math/MtxExpr.h · Cross-compiler

Overload 3: TVec *SortDescend(int Index, int Len, TVecInt *IndexVec) const;

Sort calling vector elements [Index]..[Index+Len-1].

#NameTypeDescription
1Indexint
2Lenint
3IndexVecTVecInt *
Remarks:

An exception is raised if Vector::ConditionCheck is True and array borders are overrun. IndexVec contains the new order of elements.

Declared in Dew::Math::Vector · Dew.Math/MtxExpr.h · Cross-compiler

Overload 4: TVec *SortDescend(TVecInt *IndexVec) const;

Sort all calling vector elements. IndexVec contains contains the new order of elements.

#NameTypeDescription
1IndexVecTVecInt *
Declared in Dew::Math::Vector · Dew.Math/MtxExpr.h · Cross-compiler