procedure QuickSort(const AList: TStrings; const AStart, AEnd: Integer); procedure Swap(const AIdx1, AIdx2: Integer); var Tmp: string; begin Tmp := AList[AIdx1]; AList[AIdx1] := AList[AIdx2]; AList[AIdx2] := Tmp; end; var Left: Integer; Pivot: string; Right: Integer; begin if AStart >= AEnd then Exit; Pivot := AList[AStart]; Left := AStart + 1; Right := AEnd; while Left < Right do begin if AList[Left] < Pivot then Inc(Left) else begin Swap(Left, Right); Dec(Right); end; end; Dec(Left); Swap(Left, AStart); Dec(Left); QuickSort(AList, AStart, Left); QuickSort(AList, Right, AEnd); end; //delphi/4526