"ansible_facts": {
"list1": [
"10",
"2",
"4",
"5",
"6",
"7",
"7",
"8",
"9"
],
"list2": [
[
"10",
"xxxxx"
],
[
"2",
"yyyyy"
],
[
"4",
"zzzzz"
],
[
"5",
"mmmmm"
],
[
"6",
"fffff"
],
[
"7",
"gggggg"
],
[
"8",
"hhhhh"
],
[
"9",
"kkkkkk"
]
Here I have two lists, I want to merge list2, just the words(xxxx,yyyy,...) with list1, but with condition that whenever the number on list2 match list1 then merge it to it's according number on list 1. But as you can see there can be some repeating number making it not perfectly aligned. When I sort the list like above still the the condition won't work when numbers repeat.
``
the condition that i've tried
when: list1[item|int] == list2[item|int]
with_sequence: start=0 end={{countvar.stdout|int - 1}}
Expected merged list
```
"list3": [
[
"10",
"xxxxx"
],
[
"2",
"yyyyy"
],
[
"4",
"zzzzz"
],
[
"5",
"mmmmm"
],
[
"6",
"fffff"
],
[
"7",
"gggggg"
],
[
"7",
"gggggg"
],
[
"8",
"hhhhh"
],
[
"9",
"kkkkkk"
]