Vector.SortDescend Method

Overload List

#SignatureDescription
1TVec SortDescendSorts vector elements in descending order.
└ indexed: TVec SortDescend(Int32 Index, Int32 Len)
2TVec SortDescend(TVecInt IndexVec)Sort all calling vector elements. IndexVec contains contains the new order of elements.
└ indexed: TVec SortDescend(Int32 Index, Int32 Len, TVecInt IndexVec)

Overload 1: TVec SortDescend

Sorts vector elements in descending order.

Result: stored in self (calling object), returns self for chaining

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
Vector a = new Vector();
a.SetIt(new double[] { 1.0, 2.0, 3.0, 4.0 });
a.SortDescend();
Vector expected = new Vector();
expected.SetIt(new double[] { 4.0, 3.0, 2.0, 1.0 });
if (!a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute))
    throw new Exception("Vector.SortDescend: mismatch");
Vector a;
a.SetIt(true,new double[] {2,1,3,4});
a.SortDescend; // a = new double[] {4,3,2,1}
See Also: Vector.SortAscend

Indexed: TVec SortDescend(Int32 Index, Int32 Len)

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

#NameTypeDescription
1IndexInt32start index
2LenInt32element count

Result: stored in self (calling object), returns self for chaining

Remarks:

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

Overload 2: TVec SortDescend(TVecInt IndexVec)

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

#NameTypeDescription
1IndexVecTVecIntsource TVecInt

Result: stored in self (calling object), returns self for chaining

Indexed: TVec SortDescend(Int32 Index, Int32 Len, TVecInt IndexVec)

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

#NameTypeDescription
1IndexInt32start index
2LenInt32element count
3IndexVecTVecIntsource TVecInt

Result: stored in self (calling object), returns self for chaining

Remarks:

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