Vector.SortAscend Method

Overload List

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

Overload 1: function SortAscend: TVec;

Sorts vector elements in ascending order.

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

Remarks:

Sort all calling vector elements.

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

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

Indexed: function SortAscend(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 SortAscend(const IndexVec: TVecInt): TVec;

Sort all calling vector elements. IndexVec contains the new (zero based) order of elements.

#NameTypeDescription
1IndexVecTVecInt

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

Remarks:

The order is stored in an array of integers which are accessible via the IValues property.

Indexed: function SortAscend(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. The order is stored in an array of integers which are accessible via the IValues property.