Hi. I am trying to shuffle a 2d list D= [[2, 2, 2, 3, 3, 2, 4, 4, 2, 4], [‘S1’, ‘S2’, ‘S3’, ‘S4’, ‘S5’, ‘S6’, ‘S7’, ‘S8’, ‘S9’, ‘S10’]] where D[0] are the values to be shuffled and D[1] is the index of the values. I want to random shuffle the D[0] and add the updated index value in the list. For example: It can be D= [[4, 4, 4, 3, 3, 2, 2, 2, 2, 2], [‘S7’, ‘S8’, ‘S10’, ‘S4’, ‘S5’, ‘S1’, ‘S2’, ‘S3’, ‘S6’, ‘S9’]]
If I do random.shuffle(D), it shuffles the D[0] and D[1] which I don’t want. If I do random.shuffle(D[0]) then it shuffles the D[0] and the index values are intact. How do I shuffle the D[0] and get the updated index values?