сортировка таблицы
Привет! Подскажите, как сделать сортировку таблицы. Я вот написал, но что-то не работает.
procedure TForm2.Button9Click(Sender: TObject);
Var k,a,b,c,d,e,v,x,k1,a1,b1,c1,d1,e1,v1,x1,k2,a2,b2,c 2,d2,e2,v2,x2:string;
begin
with StringGrid1 do
begin
if Cells[7,1]<Cells[7,2] then
begin
k:=Cells[0,2];
Cells[0,2]:=Cells[0,1];
Cells[0,1]:=k;
a:=Cells[1,2];
Cells[1,2]:=Cells[1,1];
Cells[1,1]:=a;
b:=Cells[2,2];
Cells[2,2]:=Cells[2,1];
Cells[2,1]:=b;
c:=Cells[3,2];
Cells[3,2]:=Cells[3,1];
Cells[3,1]:=c;
d:=Cells[4,2];
Cells[4,2]:=Cells[4,1];
Cells[4,1]:=d;
e:=Cells[5,2];
Cells[5,2]:=Cells[5,1];
Cells[5,1]:=e;
v:=Cells[6,2];
Cells[6,2]:=Cells[6,1];
Cells[6,1]:=v;
x:=Cells[7,2];
Cells[7,2]:=Cells[7,1];
Cells[7,1]:=x;
end;
if Cells[7,2]<Cells[7,3] then
begin
k1:=Cells[0,2];
Cells[0,2]:=Cells[0,1];
Cells[0,1]:=k1;
a1:=Cells[1,2];
Cells[1,2]:=Cells[1,1];
Cells[1,1]:=a1;
b1:=Cells[2,2];
Cells[2,2]:=Cells[2,1];
Cells[2,1]:=b1;
c1:=Cells[3,2];
Cells[3,2]:=Cells[3,1];
Cells[3,1]:=c1;
d1:=Cells[4,2];
Cells[4,2]:=Cells[4,1];
Cells[4,1]:=d1;
e1:=Cells[5,2];
Cells[5,2]:=Cells[5,1];
Cells[5,1]:=e1;
v1:=Cells[6,2];
Cells[6,2]:=Cells[6,1];
Cells[6,1]:=v1;
x1:=Cells[7,2];
Cells[7,2]:=Cells[7,1];
Cells[7,1]:=x1;
if Cells[7,1]<Cells[7,3] then
begin
k2:=Cells[0,2];
Cells[0,2]:=Cells[0,1];
Cells[0,1]:=k2;
a2:=Cells[1,2];
Cells[1,2]:=Cells[1,1];
Cells[1,1]:=a2;
b2:=Cells[2,2];
Cells[2,2]:=Cells[2,1];
Cells[2,1]:=b2;
c2:=Cells[3,2];
Cells[3,2]:=Cells[3,1];
Cells[3,1]:=c2;
d2:=Cells[4,2];
Cells[4,2]:=Cells[4,1];
Cells[4,1]:=d2;
e2:=Cells[5,2];
Cells[5,2]:=Cells[5,1];
Cells[5,1]:=e2;
v2:=Cells[6,2];
Cells[6,2]:=Cells[6,1];
Cells[6,1]:=v2;
x2:=Cells[7,2];
Cells[7,2]:=Cells[7,1];
Cells[7,1]:=x2;
end;
end;
end;
end;
|