The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



SortElems


Unit:SDL_vector
Class:TVector, TIntVector
Declaration:procedure SortElems (Ascending: boolean; RangeFirst, RangeLast: integer);

The method SortElems provides a means to sort the elements of a vector or part of it. The vector is sorted within the range RangeFirst and RangeLast. The values outside this range are not affected. If both RangeFirst and RangeLast are set to zero values the entire vector is sorted. The parameter Ascending specifies whether the valus are to be sorted in ascending (TRUE) or descending (FALSE) order.

The event OnSortExchange is generated whenever two elements have to be exchanged during the sorting process. The sorting is performed by a modified bubble sort (CombSort), which has been reported to be comparable in speed to QuickSort (see also R.Box, S. Lacey, BYTE magazine, April 1991).

Example: The statement V1.SortElems (true, 1, V1.NrOfElems) sorts the whole vector V1 in ascending order.


Last Update: 2014-Mar-27