2D array sort using function - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

2D array sort using function

salletkdsalletkd Posts: 5Member
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
read(a[i,j]);
end;
write('Press anykey');
readkey;
for i:=1 to 3 do
for j:=1 to 2 do
begin
writeln(sort(a));
end;
readkey;
end.
[/code]
Another question, what's this sort called? Bubblesort or Selection sort? Or something third?
Sign In or Register to comment.