Error: object of type 'int' has no len()
<p>I have a function that is supposed to take an array and sort it from the smallest string size to the largest and then print it by using injection sort.</p>

<p>On the line: <code>while (j &gt;=0) and (len(b[j]) &gt; key):</code></p>

<p>I get this error: </p>

<blockquote>
  <p>object of type 'int' has no len()</p>
</blockquote>

<p>Code:</p>

<pre><code>def list_sort(b):
    for i in range(1, len(b)):
        key = len(b[i])
        j = i - 1 
        while (j &gt;=0) and (len(b[j]) &gt; key):
            b[j+1] = b[j]
            j = j - 1
        b[j+1] = key
    for i in range( len(b) ):
        print (b[i])

list_sort(name)
</code></pre>