# 2D array sort using function

Hi. I've started programming recently so I'm a newbie. I checked how functions work, and tried to sort 2D array using function. Here's the code:
[code]

program functionSort;
uses crt;
var a:array of integer;
i,j:integer;

function sort(a:array of integer):array of integer;
var i,j,k,l,tmp:integer;
begin
for i:=1 to 3 do
for j:=1 to 2 do
for k:=1 to 3 do
for l:=1 to 2 do
begin
if a[i,j]>a[k,l] then
begin
tmp:=a[i,j];
a[i,j]:=a[k,l];
a[k,l]:=tmp;
end;
end;
sort:=a;
end;

begin
for i:=1 to 3 do
for j:=1 to 2 do
begin
end;
write('Press anykey');
for i:=1 to 3 do
for j:=1 to 2 do
begin
writeln(sort(a));
end;
end.
[/code]
Another question, what's this sort called? Bubblesort or Selection sort? Or something third?

• Sorry for the double post, the forum got bugged.
In 1st var line i for got to add array length, and in function line.
Also at the last writeln i added sort(a[i,j])
Here's how it looks now:
[code]

program functionSort;
uses crt;
var a:array[1..3,1..2] of integer;
i,j:integer;

function sort(a:array[1..3,1..2] of integer):array[1..3,1..2] of integer;
var i,j,k,l,tmp:integer;
begin
for i:=1 to 3 do
for j:=1 to 2 do
for k:=1 to 3 do
for l:=1 to 2 do
begin
if a[i,j]>a[k,l] then
begin
tmp:=a[i,j];
a[i,j]:=a[k,l];
a[k,l]:=tmp;
end;
end;
sort:=a;
end;

begin
for i:=1 to 3 do
for j:=1 to 2 do
begin
end;
write('Press anykey');
for i:=1 to 3 do
for j:=1 to 2 do
begin
writeln(sort(a));
end;