擅长:python、mysql、java
<p>你基本上需要检查你的列表开始持有奇数或偶数!基于此,你需要逆转!你知道吗</p>
<pre><code>>>> s
(7, 3, 5, 1, 2, 4, 6, 8)
>>> sorted(filter(lambda x:(x%2!=0 and s[0]%2!=0) or (x%2==0 and s[0]%2==0),s)) + sorted(filter(lambda x:(x%2!=0 and s[-1]%2!=0) or (x%2==0 and s[-1]%2==0),s))
[1, 3, 5, 7, 2, 4, 6, 8]
</code></pre>