I think I would have sorted them into lists of consecutive integers (assuming each number can appear only once)
take first number
if the number 1 lower than or 1 higher than a number in an existing list?
yes: pre/post pend existing list
no : create a new list starting with the current number
if there are more numbers, return to top
display the longest list