Python sort strings started with digits
<p>I have the next list:</p>

<pre><code>a = ['1th Word', 'Another Word', '10th Word']
print a.sort()
&gt;&gt;&gt; ['10th Word', '1th Word', 'Another Word']
</code></pre>

<p>But I need:</p>

<pre><code>['1th Word', '10th Word','Another Word']
</code></pre>

<p>Is there an easy way to do this?</p>

<p>I tried:</p>

<pre><code>r = re.compile(r'(\d+)')
def sort_by_number(s):
    m = r.match(s)
    return m.group(0)

x.sort(key=sort_by_number)
</code></pre>

<p>But some strings do not have numbers and this leads to an errors.
Thanks.</p>
