To download NI software, including the products shown below, visit ni.com/downloads.
Overview
The example demonstrates how to randomize the order of an array.
Description
To randomize the order of an array there are many possibilities. In this case the example generates a random array with the same length and is sorted. Looking at the indices of the array after the sort, you get a pretty random order that can be used to rearrange the input array in a random way.
Requirements
Software
Hardware
Steps to Implement or Execute Code
Additional Information or References
Remark:
A previous example used another algorithm to randomize the order of the input array. Since the calculation takes orders of magnitudes longer to calculate and does not effectively randomize longer arrays (>300 elements), the algorithm has been changed to reduce memory access and the number of random number generation.
Also as already mentioned in the comments:
The 'Riffle' function can be used to achive the same task.
**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text 'NIVerified'. Read here for more information about the new Example Guidelines and Community Platform.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Hey Dr.Horrible,
Good example. If anyone has at least the full version, they can also use the "Riffle" function to get the same functionality. Cheers!
There a several problem:
For a better solution, see my comment here for a much easier way.
...and if you have anything above LabVIEW base, use riffle. No code needed.