Function to merge sorted lists
ignacio at openservices.net
Fri Aug 31 03:42:42 CEST 2001
On Thu, 30 Aug 2001, Edward C. Jones wrote:
> Has anyone written in C a merge function for sorted Python sequences? It
> should look like:
> merged_list, tail1, tail2 = merge(list1, list2)
> where either tail1 or tail2 is . Suppose tail1 is . Then tail2 is a
> terminal sublist of list2, the last element of merged_list is the last
> element of list1, and merged_list + tail2 is the merger of list1 and
> list2. Similarly if tail2 is .
> This function would be useful for writing external merge sort programs.
> Ed Jones
Sounds interesting, but... and don't take this the wrong way... I can barely
understand what you're trying to say. An example might help.
It's doable, but tail1 and tail2 would both have to be arguments to the
function as well. Also, what happens if both tail1 and tail2 are ? Also,
what should/will be in the non-empty one?
Ignacio Vazquez-Abrams <ignacio at openservices.net>
More information about the Python-list