Что мне не хватает?
Код: Выделить всё
theList = [{"V":"1"}, {"V":"2"}, {"V":"3"}, {"V":"4"}, {"V":"5"}]
i = -1
for vMove in {"4", "5"}:
for listDict in theList:
i += 1
vName = listDict.get("V")
if vName == vMove:
break
theList.insert(0, theList.pop(i))
i = -1
print(theList)
Код: Выделить всё
[{'V': '5'}, {'V': '4'}, {'V': '1'}, {'V': '2'}, {'V': '3'}]
Код: Выделить всё
[{'V': '4'}, {'V': '5'}, {'V': '1'}, {'V': '2'}, {'V': '3'}]
Подробнее здесь: https://stackoverflow.com/questions/790 ... t-of-order