擅长:python、mysql、java
<p>让我们从编写一个比较函数开始</p>
<pre><code>def cmp_lists(L1,L2):
'''returns the first item of the lesser list and the remaining lists'''
if L1 < L2:
return L1[0],(L1[1:],L2)
return L2[0],(L1,L2[1:])
</code></pre>
<p>现在编写一个合并两个列表的方法</p>
^{pr2}$