Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

two lists with identical entries get order

from collections import defaultdict, deque

indexes = defaultdict(deque)
for i, x in enumerate(lst2):
    indexes[x].append(i)

ids = [indexes[x].popleft() for x in lst1]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #lists #identical #entries #order
ADD COMMENT
Topic
Name
3+9 =