Vector.SortDescend Method

Overload List

#SignatureDescription
1function SortDescend: TVec;Sorts vector elements in descending order.
└ indexed: function SortDescend(Index: Integer; Len: Integer): TVec;
2function SortDescend(const IndexVec: TVecInt): TVec;Sort all calling vector elements. IndexVec contains contains the new order of elements.
└ indexed: function SortDescend(Index: Integer; Len: Integer; const IndexVec: TVecInt): TVec;

Overload 1: function SortDescend: TVec;

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
var a: Vector;
begin
    a.SetIt(True,[2,1,3,4]);
    a.SortDescend; // a = [4,3,2,1]
var
    a, expected: Vector;
begin
    a := [1.0, 2.0, 3.0, 4.0];
    a.SortDescend;
    expected := [4.0, 3.0, 2.0, 1.0];
    if not a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute) then
        raise Exception.Create('Vector.SortDescend: mismatch');
end;
See Also: Vector.SortAscend

Indexed: function SortDescend(Index: Integer; Len: Integer): TVec;

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

#NameTypeDescription
1IndexIntegerstart index
2LenIntegerelement count

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

Remarks:

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

Overload 2: function SortDescend(const IndexVec: TVecInt): TVec;

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

#NameTypeDescription
1IndexVecTVecInt

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

Indexed: function SortDescend(Index: Integer; Len: Integer; const IndexVec: TVecInt): TVec;

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

#NameTypeDescription
1IndexIntegerstart index
2LenIntegerelement count
3IndexVecTVecInt

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

Remarks:

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