marpis
2009-08-25 09:41:47
Self explanatory
E: I didn't write this myself, if someone missed that :rolleyes:
E: I didn't write this myself, if someone missed that :rolleyes:
procedure QuickSortEx(var A: array of Extended; iLo, iHi: Integer);
var
Lo, Hi: Integer;
Pivot, T: Extended;
begin
Lo := iLo;
Hi := iHi;
Pivot := A[(Lo + Hi) div 2];
repeat
while A[Lo] < Pivot do Inc(Lo) ;
while A[Hi] > Pivot do Dec(Hi) ;
if Lo <= Hi then
begin
T := A[Lo];
A[Lo] := A[Hi];
A[Hi] := T;
Inc(Lo) ;
Dec(Hi) ;
end;
until Lo > Hi;
if Hi > iLo then QuickSortEx(A, iLo, Hi) ;
if Lo < iHi then QuickSortEx(A, Lo, iHi) ;
end;
A := [2.2, 1.2, 4.3, 6.4, 2.1];
QuickSortEx(A, Low(A), High(A));