Delphi for quick sorting of integer arrays

From , 5 Years ago, written in Delphi (Object Pascal), viewed 231 times.
URL https://pastebin.vip/view/9f810ebd
  1. procedure QSort(var A: array of Integer);
  2.   procedure QuickSort(var A: array of Integer; iLo, iHi: Integer);
  3.   var Lo, Hi, Mid, T: Integer;
  4.   begin
  5.     Lo := iLo;
  6.     Hi := iHi;
  7.     Mid := A[(Lo + Hi) div 2];
  8.     repeat
  9.       while A[Lo] < Mid do
  10.         Inc(Lo);
  11.       while A[Hi] > Mid do
  12.         Dec(Hi);
  13.       if Lo <= Hi then begin
  14.         T := A[Lo];
  15.         A[Lo] := A[Hi];
  16.         A[Hi] := T;
  17.         Inc(Lo);
  18.         Dec(Hi);
  19.       end;
  20.     until Lo > Hi;
  21.     if Hi > iLo then
  22.       QuickSort(A, iLo, Hi);
  23.     if Lo < iHi then
  24.       QuickSort(A, Lo, iHi);
  25.   end;
  26. begin
  27.   QuickSort(A, Low(A), High(A));
  28. end;
  29. //delphi/4527

Reply to "Delphi for quick sorting of integer arrays"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website