```Contributor: TEEMU.KIVINIEMI

program sort_nodenumbers;

(* This is an example which sorts Fidonet node numbers. *)
(* The routine is very slow and basic, but it works. *)

(* Made in January/1996 by Teemu Kiviniemi, 2:229/222@fidonet.org *)

type node=record
zone,net,node:word;
end;

const nodecount=1000;

var c:word;
temp:node;
nodes:array[0..nodecount] of node;

procedure swap(var a,b:word);
var temp:word;
begin
temp:=a;
a:=b;
b:=temp;
end;

procedure printnumbers;
var b:word;
begin
for b:=0 to nodecount do
writeln(nodes[b].zone,':',nodes[b].net,'/',nodes[b].node);
end;

begin
randomize;
for c:=0 to nodecount do
begin
nodes[c].zone:=random(6)+1;
nodes[c].net:=random(998)+1;
nodes[c].node:=random(998)+1;
end;
writeln('Before sorting:');
printnumbers;
{ Sort the zones }
writeln('Zones...');
repeat
for c:=0 to nodecount-1 do
if nodes[c].zone> nodes[c+1].zone then
begin
swap(nodes[c].zone,nodes[c+1].zone);
end;
{ Sort the nets }
writeln('Nets...');
repeat
for c:=0 to nodecount-1 do
if (nodes[c].net> nodes[c+1].net) and
(nodes[c].zone=nodes[c+1].zone) then
begin
swap(nodes[c].net,nodes[c+1].net);
end;
{ Sort the nodes }
writeln('Nodes...');
repeat
for c:=0 to nodecount-1 do
if (nodes[c].node> nodes[c+1].node) and
(nodes[c].net=nodes[c+1].net) and
(nodes[c].zone=nodes[c+1].zone) then
begin
swap(nodes[c].node,nodes[c+1].node);