How do I randomize or shuffle the elements within an array in Swift? For example, if my array consists of 52 playing cards, I want to shuffle the array in o
It stop at "swap(&self[i], &self[j])" when I upgrade the xCode version to 7.4 beta. fatal error: swapping a location with itself is not supported
I found the reason that i = j (function of swap will exploded)
So I add a condition as below
if (i != j){ swap(&list[i], &list[j]) }
YA! It's OK for me.