Midware TMWBuffer.Sort

From Overbyte
Revision as of 15:22, 14 May 2011 by Marie (talk | contribs) (→‎Example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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>