From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
Shuffles (rearranges randomly) the elements of an array.
|array||Any valid data type||The array whose elements will be shuffled.|
Shuffle works on arrays of any data type and any number of dimensions. It is based on a random number. An element of the original array has a roughly equal chance of appearing in any cell of the array after the shuffle, regardless of the size and number of dimensions of the array.
A Fisher-Yates shuffle is used. There is no ability to control the seed.
Shuffle a one-dimensional array:
Var result As String
For i As Integer = 0 To values.LastRowIndex
result = result + i.ToString
Shuffle a two-dimensional array:
For i As Integer = 0 To 5
For j As Integer = 0 To 5
myArray(i, j) = i.ToString + j.ToString