type
plist=^node;
node=record
data: integer;
next:plist;
end;
function insert_sort(l: plist): plist;
function insert(a: plist; l: plist): plist;
begin
a^.next := nil;
if l = nil then insert := a
else
if a^.data < l^.data then begin
a^.next := l; insert := a;
end
else begin
l^.next := insert(a, l^.next);
insert := l;
end;
end;
begin
if l = nil then insert_sort := nil
else insert_sort := insert(l, insert_sort(l^.next));
end;
Var first: plist;
...
{ Заполнение списка }
first := insert_sort(first);
...
begin
if l = nil then insert_sort := nil
else insert_sort := insert(l, insert_sort(l^.next));
end;