Midware TMWBuffer.Sort

From Overbyte
Jump to navigation Jump to search

Main page -> Midware component reference -> TMWBuffer -> Sort

Definition

procedure Sort(BuildKey:TMWBufferSortBuildKey;Ascending:Boolean);

Description

Sort will sort TMWBuffer content. Sort is based on keys. Keys are built by an external function passed as BuildKey argument. Sort will scan all records, calling BuildKey to build an array of keys. The array is sorted and TMWBuffer data reorganized accordingly.

If BuildKey is nil, then a default function is used instead. This default function use first fireld as key.

Example

<syntaxhighlight lang="delphi"> procedure TForm1.Button1Click(Sender: TObject); begin

   MWBuffer1.Sort(MyBuildKeyFunction, TRUE);

end;

function MyBuildKeyFunction(MWBuffer : TMWBuffer) : String; begin

   Result := MWBuffer.Fields[0] + ' ' + 
             MWBuffer.Fields[1];

end; </syntaxhighlight>