Interesting (?) problem
Paul Rubin
no.email at nospam.invalid
Mon Jan 11 13:42:32 EST 2010
mk <mrkafk at gmail.com> writes:
> I have two lists of IP addresses:
>
> hostips = [ 'a', 'b', 'c', 'd', 'e' ]
>
> thread_results = [ 'd', 'b', 'c' ]
>
> I need to sort thread_results in the same order as hostips.
Assuming each address in hostips appears just once:
from itertools import izip,count
d = dict(izip(hostips, count()))
sorted_results = sorted(thread_results, key=d.get)
More information about the Python-list
mailing list