title: Delphi sorting String grid
body: <p>in matrix(StringGrid) NxM sort the elements of each row in nondecreasing order?</p>
  
  <pre><code>var
    Form1: TForm1;
    n,m:integer;
    I:integer;
  
  implementation
  
  {$R *.dfm}
  
  procedure TForm1.btNapraviClick(Sender: TObject);
  begin
    with StringGrid1 do
    begin
      n:=StrToInt(edN.text)+1;
      m:=StrToInt(edM.text)+1;
      ColCount:=n;
      RowCount:=m;
  
      for I:=0 to n-1 do Cells[I,0]:=IntToStr(I);
      for I:=1 to m-1 do Cells[0,I]:=IntToStr(I);
    end;
  end;
  
  procedure TForm1.Button1Click(Sender: TObject);
  var J,P,K:integer;
  begin
    with StringGrid1 do
    begin
      for I:=1 to n do
        for J:=1 to m-1 do
          for K:=J+1 to m do
          begin
            if StrToInt(Cells[I,J]) &lt;= StrToInt(Cells[I,K]) then
            begin
              P:=StrToInt(Cells[I,J]);
              Cells[I,J]:=(Cells[I,K]);
              Cells[I,K]:=IntToStr(P);
            end;
          end;
    end;
  end;
  </code></pre>