title: TypeError: '<' not supported between instances of 'tuple' and 'str'
body: <p>I have a method that build huffman tree which is as follows:</p>
  
  <pre><code>def buildTree(tuples) :
      while len(tuples) &gt; 1 :
          leastTwo = tuple(tuples[0:2])                  # get the 2 to combine
          theRest  = tuples[2:]                          # all the others
          combFreq = leastTwo[0][0] + leastTwo[1][0]     #enter code here the branch points freq
          tuples   = theRest + [(combFreq,leastTwo)]     # add branch point to the end
          tuples.sort()                                  # sort it into place
      return tuples[0]            # Return the single tree inside the list
  </code></pre>
  
  <p>but while I feed the function with following parameter:</p>
  
  <pre><code>[(1, 'b'), (1, 'd'), (1, 'g'), (2, 'c'), (2, 'f'), (3, 'a'), (5, 'e')]
  </code></pre>
  
  <p>I get the error as </p>
  
  <pre><code>  File "&lt;stdin&gt;", line 7, in buildTree
      tuples.sort()
  TypeError: '&lt;' not supported between instances of 'tuple' and 'str'
  </code></pre>
  
  <p>While debugging I found the error was in <code>tuples.sort()</code>.</p>