If all lines are numbered, then just put the line numbers in an array and sort them. There are lots of sort routines around. You could even use the dos sort if thats available on your os. If you use the sorted array approach, once sorted, go back and check the line up to len of the array versus...