擅长:python、mysql、java
<p>您可以使用<code>sorted()</code>并从字符串中提取数字,将数字用作<code>sorted</code>中的键</p>
<pre><code>res = sorted(my_list, key=lambda x: int(x.split('-SD')[-1]))
print(res)
</code></pre>
<p><strong>输出:</strong></p>
<pre><code>['STNNC-BDD-SD01', 'STNNC-BDB-SD02', 'STNNC-A11-SD03', 'STNNC-BDD-SD04']
</code></pre>