How to randomly change the order of an array's elements?

Hi.

I have an array of target points and I want to make it unsorted randomly

Here is a possible algorithm. Loop the number of times of elements in the input array. In each loop use the Random Int in Range node with minimum 0 and max set to the number of elements in the input array. Take the random int generated as the Get At index node to get a value from the input array and copy it to the new output array. Each time you read a value from the input array mark it as read by inserting a true into another tracking array of booleans initialized to false that is the size of the input array. Whenever the value to get from the input array has already been read, try to access the next element (n+1). Continue the loop to the end and all elements will be copied to the output array. The output array is now randomly sorted.

1 Like

thank you man.

this algorithm sounds to be correct however, fortunately EPIC has already made it easy for us by “Shuffle” node which I just figured out.

but I am gonna mark your answer which was great.

thanks