Created
April 26, 2015 10:00
Revisions
-
MartinJNash created this gist
Apr 26, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ extension Array { var shuffled: Array<T> { var newer = self newer.shuffle() return newer } mutating func shuffle() { let count = self.count if count > 1 { for x in 0..<count { let idx = Int(arc4random_uniform(UInt32(x+1))) swap(&self[x], &self[idx]) } } } }