const n=3;
m=2;
var i,j,z,T,B,k:integer;
a: array [1..n,1..m] of integer;
begin
for i:=1 to n do
for j:=1 to m do
read(a[i,j]);
writeln('Массив до сортировки: ');
for i:=1 to n do
begin
for j:=1 to m do write(a[i,j]:3);
writeln;
end;
k:=2;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i,k]>a[j,k] then
begin
T:=a[j,k];
a[j,k]:=a[i,k];
a[j,k]:=T;
for z:=1 to m do
if z=k then continue
else
begin
B:=a[j,z];
a[j,z]:=a[i,z];
a[j,z]:=B;
end;
end;
writeln;
writeln('Массив после сортировки: ');
for i:=1 to n do
begin
for j:=1 to m do write(a[i,j]:3);
writeln;
end;
end.