One way would be to read in the file, split the lines, put the lines into order, then check to see whether the order is the same or different.
This might not be the most efficient way but would work:
with open('potatoes.txt') as potatoes:
potato_lines = potatoes.readlines()
print sorted(potato_lines) == potato_lines
Answers to this question show you how to check without sorting.
e.g, this answer gives a neat way of generating pairs to check order:
from itertools import tee, izip
def pairwise(iterable):
a, b = tee(iterable)
next(b, None)
return izip(a, b)
def is_sorted(iterable, key=lambda a, b: a <= b):
return all(key(a, b) for a, b in pairwise(iterable))
Which you could then use:
with open('potatoes.txt') as potatoes:
print is_sorted(potatoes)