Advertisement
Guest User

BubbleSort

a guest
Sep 2nd, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.42 KB | None | 0 0
  1. function BubbleSort(array : TStringList) : TStringList;
  2. var
  3.     i, j: Integer;
  4.     aux : String;
  5. begin
  6.  
  7.   aux :='';
  8.  
  9.   for i:=0 to array.Count-1 do
  10.   begin
  11.     for j:=0 to array.Count-2 do
  12.     begin
  13.         if (StrToInt(Copy(array[j],1,1)) > StrToInt(Copy(array[j+1],1,1))) then
  14.         begin
  15.                 aux := array[j];
  16.                 array[j] := array[j+1];
  17.                 array[j+1] := aux;
  18.         end;
  19.     end;
  20.   end;
  21.  
  22.   Result := array;
  23.  
  24. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement