title: How do I sort a string in alphabetical order in Python?
body: <p>I know there is a sort function:</p>
  
  <pre><code>&gt;&gt;&gt; a = 'bags'
  &gt;&gt;&gt; ''.join(sorted(a))
  'abgs'
  </code></pre>
  
  <p>However, I need to write mine from scratch. I think I would like to use mergesort but I'm not sure how that would work for a string in Python. E.g., can I compare characters? Can I find the middle of a string somehow?</p>
  
  <p>I'm using Python 3.4.</p>