How does python compare strings and integers
<p>In the following code below this is a simple algorithm written to sort the elements.My question is that how are strings are compared internally and how the interpreter knows that these strings are to be placed after the integers</p>

<pre><code>a=[22, 66, 54, 11, 16, 2, 5, 'b', 'a', 3, 2, 1] 
&gt;&gt;&gt; for i in range(len(a)-1):
...    for j in range(len(a)-i-1):
...       if a[j] &gt; a[j+1]:
...          a[j],a[j+1]=a[j+1],a[j]
...
&gt;&gt;&gt; print a
[1, 2, 2, 3, 5, 11, 16, 22, 54, 66, 'a', 'b']
</code></pre>
