# Why did I use Shuffle, but the position of the array element was not disturbed

**URL:** <https://forums.unrealengine.com/t/why-did-i-use-shuffle-but-the-position-of-the-array-element-was-not-disturbed/445701>\
**Category:** Blueprint\
**Tags:** randomize-array, unreal-engine, UE4, Blueprint, question\
**Created:** [March 21, 2019, 10:27am UTC](https://forums.unrealengine.com/t/why-did-i-use-shuffle-but-the-position-of-the-array-element-was-not-disturbed/445701 "2019-03-21T10:27:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![A1exHuang](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@A1exHuang](https://forums.unrealengine.com/u/A1exHuang)\
**Post date:** [March 21, 2019, 10:27am UTC](https://forums.unrealengine.com/t/why-did-i-use-shuffle-but-the-position-of-the-array-element-was-not-disturbed/445701/1 "2019-03-21T10:27:02Z")

</div>

If I don’t connect the first array to For each loop, the position of its array elements will be disrupted. Why?

 ![271943-qq截图20190321182417.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/0/8/d08b5d084b50af679357cf08ac9857bc73f30753.png)

---

<div class="post-metadata">

**Author:** ![Stormrage256](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/stormrage256/32/1008648_2.png) [@Stormrage256](https://forums.unrealengine.com/u/Stormrage256)\
**Post date:** [March 21, 2019, 11:15am UTC](https://forums.unrealengine.com/t/why-did-i-use-shuffle-but-the-position-of-the-array-element-was-not-disturbed/445701/2 "2019-03-21T11:15:31Z")

</div>

I think what’s happening here is that the Shuffle & ForEachLoop operations are calling separate instances of the make array node. So basically during each call, a whole new array just gets created.

So try storing the make array result in an array variable, then shuffle this stored array, and then pass on the variable to the ForEachLoop. That should give you the intended result.

---

<div class="post-metadata">

**Author:** ![duderseb](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/duderseb/32/558202_2.png) [@duderseb](https://forums.unrealengine.com/u/duderseb)\
**Post date:** [March 21, 2019, 11:34am UTC](https://forums.unrealengine.com/t/why-did-i-use-shuffle-but-the-position-of-the-array-element-was-not-disturbed/445701/3 "2019-03-21T11:34:01Z")

</div>

OP, did you downvote Stormrage256’s answer? He’s correct - the reason why your array isn’t shuffling is because you’re never storing it anywhere for it to be shuffled. You’re creating it twice, once for the Shuffle node (which isn’t being passed so it’s a waste, really), and again in your forLoop.

---

<div class="post-metadata">

**Author:** ![A1exHuang](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@A1exHuang](https://forums.unrealengine.com/u/A1exHuang)\
**Post date:** [March 21, 2019, 1:11pm UTC](https://forums.unrealengine.com/t/why-did-i-use-shuffle-but-the-position-of-the-array-element-was-not-disturbed/445701/4 "2019-03-21T13:11:32Z")

</div>

Sorry, I didn’t veto it. I just tried his way and managed to solve the problem, thanks to everyone who answered the question.

---

<div class="post-metadata">

**Author:** ![Anglish](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anglish](https://forums.unrealengine.com/u/Anglish)\
**Post date:** [October 7, 2023, 5:57pm UTC](https://forums.unrealengine.com/t/why-did-i-use-shuffle-but-the-position-of-the-array-element-was-not-disturbed/445701/5 "2023-10-07T17:57:28Z")

</div>

So, Right click \> promote to variable, and it works! (had to clarify cus it took me some time to find this out)
