[Tutor] Iterable Understanding
Wayne Werner
waynejwerner at gmail.com
Sat Nov 14 15:18:34 CET 2009
On Sat, Nov 14, 2009 at 7:34 AM, Stephen Nelson-Smith <sanelson at gmail.com>wrote:
>
> Well... what I want to do is create a single, sorted list by merging a
> number of other sorted lists.
>
>
Just write your own merge:
(simplified and probably inefficient and first thing off the top of my head)
newlist = []
for x, y, z in zip(list1, list2, list3):
if y > x < z:
newlist.append(x)
elif x > y < z:
newlist.append(y)
elif x > z < y:
newlist.append(z)
I'm pretty sure that should work although it's untested.
HTH,
Wayne
--
To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn’t. - Primo Levi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091114/3b7f8a3c/attachment.htm>
More information about the Tutor
mailing list