Having two lists, I want to get all the possible couples. (a couple can be only one element from list 1 and another from list 2)
If I do a double "foreach" statement, I get it immediately (I am using python):
couples = []
for e1 in list_1:
for e2 in list_2:
couples.append([l1, l2])
How can I sort couples list in a way that elements be placed in a more distributed way? for example:
list_1 = [a,b,c]
list_2 = [1,2]
I will get:
[a, 1]
[a, 2]
[b, 1]
[b, 2]
[c, 1]
[c, 2]
And expect to be sorted to something like this:
[a, 1]
[b, 2]
[c, 1]
[a, 2]
[b, 1]
[c, 2]
What algorithm should I use to get this results?