title: Python sorting in order ouput file
body: <pre><code>nums = range(201,202)
  with open('Orig.txt', 'r') as fin:
       with open('out.txt', 'w') as fout:
           for line in fin.readlines():
               line = line.split()
  
               for i in range(0, len(nums),):
                   line[1] = int(line[1]) + 1
                    #line.append(str(line[1] + 1))
                   line = [str(e) for e in line] 
                   print(line)
                   fout.write(' '.join(line) + '\n')
  </code></pre>
  
  <p>Input file</p>
  
  <pre><code>xxx1A   201 18  0   1   0   0   1
  xxx2A   201 20  0   1   0   0   1
  </code></pre>
  
  <p>Currently the output looks like this</p>
  
  <pre><code>1A  201 18  0   1   0   0   1
  1A  202 18  0   1   0   0   1
  2A  201 20  0   1   0   0   1
  2A  202 20  0   1   0   0   1
  </code></pre>
  
  <p>Whereas I would like it sorted by the third row / or second row i.e.</p>
  
  <pre><code>1A  201 18  0   1   0   0   1
  2A  201 20  0   1   0   0   1
  1A  202 18  0   1   0   0   1
  2A  202 20  0   1   0   0   1
  </code></pre>
  
  <p>Any sugestions i've tried sort / reverse etc</p>