TVec::SortDescend Method

Overload List

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

Overload 1: TVec *SortDescend();

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 "MtxVec.h"
#include "Units.MtxVec.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::MtxVec;

void Example()
{
    TVec* a;

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

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

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

#NameTypeDescription
1Indexint
2Lenint
Remarks:

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

Declared in Dew::Math::TVec · Dew.Math/MtxVec.h · Cross-compiler

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

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

#NameTypeDescription
1Indexint
2Lenint
3IndexVecTVecInt *
Remarks:

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

IndexVec contains the new order of elements.

Declared in Dew::Math::TVec · Dew.Math/MtxVec.h · Cross-compiler

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

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

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