Difference between revisions of "Midware TMWBuffer.Sort"

From Overbyte
Jump to navigation Jump to search
(Created page with ' Main page -> Midware component reference -> TMWBuffer -> Sort == Definition…')
 
 
Line 14: Line 14:
  
 
<syntaxhighlight lang="delphi">
 
<syntaxhighlight lang="delphi">
procedure TForm1.Button1Click(Sender: TObject);
+
procedure TForm1.Button1Click(Sender: TObject);
 
begin
 
begin
 
     MWBuffer1.Sort(MyBuildKeyFunction, TRUE);
 
     MWBuffer1.Sort(MyBuildKeyFunction, TRUE);

Latest revision as of 15:22, 14 May 2011

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>