Vector.SortAscend Method

Overload List

#SignatureDescription
1TVec SortAscendSorts vector elements in ascending order.
└ indexed: TVec SortAscend(Int32 Index, Int32 Len)
2TVec SortAscend(TVecInt IndexVec)Sort all calling vector elements. IndexVec contains the new (zero based) order of elements.
└ indexed: TVec SortAscend(Int32 Index, Int32 Len, TVecInt IndexVec)

Overload 1: TVec SortAscend

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

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

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

#NameTypeDescription
1IndexVecTVecIntsource TVecInt

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