title: Quickly alphabetize a large file via python
body: <pre><code>#!/usr/bin/python
  
  import random
  import string
  
  appendToFile = open("appendedFile", "a" )
  
  # Generator
  
  for i in range(1, 100000):
  
      chars = "".join( [random.choice(string.letters) for i in xrange(15)] )
      chars2 = "".join( [random.choice(string.letters) for i in xrange(15)] )
  
      appendToFile.write(chars + ":" + chars2 + "\n")
  
  appendToFile.close()
  </code></pre>
  
  <p>Code modified from <a href="https://stackoverflow.com/questions/367586/generating-random-text-strings-of-a-given-pattern">this question</a>.</p>
  
  <p>The above code generates 100,000 lines of random text in the format of STRING:STRING. Resultant text file is 3.1 MB.</p>
  
  <p>How would one rapidly alphabetise the file, using the first STRING in STRING:STRING?
  Case is irrelevant.</p>
  
  <p>Bubble sort is very slow, no?</p>