This question looks like a other stackoverflow question: Is it possible to sort two lists(which reference each other) in the exact same way?
For me the solution from this question does not work. Error: TypeError: '<' not supported between instances of 'Card' and 'Card'
I have two lists in Python. List 1 stores the number of occurences of the card. List 2 stores the card objects. An example of this I show below. This lists are directly referenced by each other. The lists are already sorted based on the rank of the card (from big to small, from ace to deuce).
cardCountList = [1, 1, 3, 3, 2]
cardList = [aceCardObject, queenCardObject, tenCardObject, eightCardObject, deuceCardObject]
What I want is to sort both lists based on the numbers in the cardCountList. But the order of the duplicate numbers must stay the same. So the end result should be:
cardCountList = [3, 3, 2, 1, 1]
cardList = [tenCardObject, eightCardObject, deuceCardObject, aceCardObject, queenCardObject]
Below code gives me the error:
cardCountList, cardList = zip(*sorted(zip(cardCountList, cardList )))
cardCountList, cardList = (list(t) for t in zip(*sorted(zip(cardCountList, cardList ))))