Program IntSort(Output, Infile, Outfile); Type ListType = ^RecType; RecType = Record Num:Integer; Next:ListType; End; Var Infile, Outfile:Text; Num:Integer; List:ListType; Procedure Insert(Var List:ListType; Num:Integer); Var Ptr, P:ListType; Begin {Insert} P := New(ListType); P^.Num := Num; If (List = NIL) OR (Num < List^.Num) Then Begin P^.Next := List; List := P; End Else Begin Ptr := List; While (Ptr^.Next <> NIL) And (Ptr^.Next^.Num <= Num) Do Ptr := Ptr^.Next; P^.Next := Ptr^.Next; Ptr^.Next := P; End; End; {Insert} Procedure PrintList(List:ListType); Var P:ListType; Begin {PrintList} P := List; While P <> NIL Do Begin Writeln(Outfile, P^.Num); P := P^.Next; End; End; {PrintList} Begin {IntSort} Assign(Infile, 'c:\NumSort.txt'); Reset(Infile); Assign(Outfile, 'c:\Report.txt'); Rewrite(Outfile); List := NIL; While Not EOF(Infile) Do Begin Readln(Infile, Num); Insert(List, Num); End; PrintList(List); Close(Outfile); End. {IntSort}