Randomize two arrays the same way Swift

后端 未结 4 2270
我寻月下人不归
我寻月下人不归 2021-01-21 04:36

I know there is a new shuffle method with iOS 9 but I am wondering if there is anyway to shuffle two arrays the same way?

For example

[1         


        
4条回答
  •  情书的邮戳
    2021-01-21 04:52

    Use a dictionary to store the values temporarily, shuffle the keys and then rebuild the other array by extracting the values from the dictionary.

提交回复
热议问题