Program P7(Output, Infile); { Insertion Sort } Const LISTSIZE = 100; Type ListType = Array [1..LISTSIZE] of Integer; Var List:ListType; Num, NumCt:Integer; Infile:Text; Function findwhere(List:ListType; Num, NumCt:Integer):Integer; Var i:Integer; Begin {findwhere} i := 1; while (i <= numct) AND (num >= list[i]) Do i := i + 1; findwhere := i; End; {findwhere} procedure makeroom(Var List:ListType; Numct, i:Integer); Var j:Integer; Begin {makeroom} j := numct; while j >= i Do Begin list[j+1] := list[j]; j := j - 1; End; End; {makeroom} Procedure insertNumInList(Var List:ListType; Num, NumCt:Integer); Var i:integer; Begin {InsertNumInList} i := findwhere(List, Num, NumCt); makeroom(List, NumCt, i); list[i] := num; End; {InsertNumInList} Procedure printlist(List:ListType; NumCt:Integer); Var i:integer; Begin {PrintList} i := 1; while i <= numct Do Begin Writeln(list[i]); i := i + 1; End; End; {PrintList} Begin {P7} Assign(Infile, 'c:\numsort.txt'); Reset(Infile); numct := 0; while not eof(Infile) Do Begin Readln(Infile, Num); insertNumInList(List, Num, NumCt); numct := numct + 1; End; printlist(List, NumCt); Readln; End. {P7}