 <p>You are reading the list wrong; <a href="https://docs.python.org/2/library/stdtypes.html#file.readline" rel="nofollow"><code>readline</code></a> does not take the line number, but the <strong>maximum number of characters per line</strong>:</p> <blockquote> <p><code>file.readline([size])</code></p> <p>Read one entire line from the file. A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line). [6] <strong>If the size argument is present and non-negative, it is a maximum byte count (including the trailing newline) and an incomplete line may be returned.</strong> When size is not 0, an empty string is returned only when EOF is encountered immediately.</p> </blockquote> <p>Your code would work if you just did <code>file.readline()</code>:</p> <pre><code>for line in range(1,11): data = file.readline() list1.append(data) </code></pre> <p>The current code tries to read only 1, 2 and 3 characters of the <em>first</em> line, which results in <code>'1'</code>, <code>'00'</code> and the <code>'\n'</code> newline being read separately, followed by max 4 characters of line 2 (<code>'200\n'</code>) etc.</p> <hr> <p>However it is not very pythonic either; I would write it as:</p> <pre><code>with open("sample.txt") as file: list1 = [ int(line) for line in file ] sortedlist = list1.sort() print sortedlist </code></pre> <p><code>with</code> automatically closes the file at the end of indented block. <code>for</code> loop for a file automatically iterates over its lines; <code>[ expression for var in iterable ]</code> is a list comprehension, that is a shorter way of doing:</p> <pre><code>result = [] for var in iterable: result.append(expression) </code></pre> <p>Or as Jon Clements suggested, if you really want to sort the lines by their numerical value, but keeping them as string:</p> <pre><code>with open('sample.txt') as file: list1 = list(file) # all lines as a list print sorted(list1, key=int) </code></pre>