Is there a way to shuffle a dictionary similar to the way we can shuffle an array?
Not directly, because a dictionary is stored as a hash table.
You can make a copy of the keys as an array, though, and sort or shuffle that. You can use that to retrieve the dictionary entries in the order of the keys in the copy.
Thanks, I was able to add a line to move its values to an array and then shuffled before reading it out as the dictionary. I hope that makes sense.
This topic was automatically closed after 166 days. New replies are no longer allowed.