mk <[email protected]> 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)
--
http://mail.python.org/mailman/listinfo/python-list
