Sign in Join
FPDoc Onlineexperiment

TFPSList.Sort procedure

Member of TFPSListpublicIn unit fgl

Sort the list.

Declaration

pascal
procedure Sort(Compare: TFPSListCompareFunc)
procedure Sort(Compare: TFPSListCompareFunc; 
 SortingAlgorithm: PSortingAlgorithm)

Arguments

Compare

Function to compare 2 items in the list.

SortingAlgorithm

Description

Sort> sorts the items in the list. Two pointers are compared by passing them to the Compare function. The result of this function determines how the pointers will be sorted:

  • If the result of this function is negative, the first item is assumed to be 'less' than the second and will be moved before the second item in the list.
  • If the function result is positive, the first item is assumed to be 'greater than' the second and will be moved after the second item in the list.
  • if the function result is zero, the pointers are assumed to be 'equal' and no moving will take place.

The sort is done using a quicksort algorithm.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.