Shuffles the collection in place.
SDK
- Xcode 10.0+
Framework
- Swift Standard Library
Declaration
Available when Self conforms to Random Access Collection.
Discussion
Use the shuffle()
method to randomly reorder the elements of an array.
This method is equivalent to calling shuffle(using:)
, passing in the system’s default random generator.
Complexity: O(n), where n is the length of the collection.