Мне помогли! кого интересует вот код!
Код HTML:
procedure TForm1.Button1Click(Sender: TObject);
var a:array of array of integer;
b:array of array of integer;
p:array of integer;
q:array of integer;
m,n,i,j,y,k:integer;
begin
N:=StrToInt(Edit1.text);
M:=StrToInt(edit2.text);
StringGrid1.colcount:=n;
StringGrid1.rowcount:=m;
StringGrid2.colcount:=n;
StringGrid2.rowcount:=m;
SetLength(a,n,m);
SetLength(b,n,m);
SetLength(p,n);
SetLength(q,n);
randomize;
for I := 0 to N-1 do
for j := 0 to M-1 do A[i,j]:=random(1000);
for I := 0 to N-1 do
for j := 0 to M-1 do StringGrid1.Cells[j,i]:=IntToStr (a[i,j]);
for I := 0 to N-1 do begin k:=0;
for j := 0 to M-1 do if A[i,j]mod 2 = 1 then k:=k+1;
p[i]:=k; q[i]:=i;
end;
for j := 0 to N - 1 do begin
for i := j+1 to N - 1 do if p[j]>p[i] then begin
y:=p[j]; p[j]:=p[i]; p[i]:=y;
y:=q[j]; q[j]:=q[i]; q[i]:=y;
end;
end;
for i := 0 to n-1 do begin
for j := 0 to m-1 do begin
b[i,j] := a[q[i],j];
end;
end;
for i := 0 to n-1 do
for j := 0 to m-1 do begin
stringgrid2.cells[j,i]:=IntToStr(b[i,j]);
end;
end;
end.