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
a=[22, 66, 54, 11, 16, 2, 5, 'b', 'a', 3, 2, 1]
>>> for i in range(len(a)-1):
... for j in range(len(a)-i-1):
... if a[j] > a[j+1]:
... a[j],a[j+1]=a[j+1],a[j]
...
>>> print a
[1, 2, 2, 3, 5, 11, 16, 22, 54, 66, 'a', 'b']