Shuffle
From Xojo Documentation
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site! |
Contents
Description
Shuffles (rearranges randomly) the elements of an array.
Syntax
array.Shuffle
Part | Type | Description |
---|---|---|
array | Any valid data type | The array whose elements will be shuffled. |
Notes
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.
Examples
The following example shuffles a one-dimensional array and shows the result in a ListBox.
aTest=Array(0,1,2,3,4,5,6,7,8,9)
aTest.Shuffle
ListBox1.Addrow Str(aTest(i))
Next
|
The following example shuffles a two-dimensional array.
For i=0 to 5
For j=0 to 5
Next
Next
myArray.Shuffle
|
See Also
Dim statement; Array, Join, Split, Ubound functions; Append, IndexOf, Insert, Redim, Remove, Pop, Sort methods; ParamArray keyword.