# Arranging objects in random rows and columns

**URL:** <https://discourse.processing.org/t/arranging-objects-in-random-rows-and-columns/28163>\
**Category:** Coding Questions\
**Created:** [March 1, 2021, 9:57am UTC](https://discourse.processing.org/t/arranging-objects-in-random-rows-and-columns/28163 "2021-03-01T09:57:42Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 1, 2021, 10:31am UTC](https://discourse.processing.org/t/arranging-objects-in-random-rows-and-columns/28163/2 "2021-03-01T10:31:56Z")

</div>

in theory, add all objects to an array A and shuffle it. (or shuffle an integer array and use it as and index)

Then you can just make a nested for-loop and add consecutively from the list A

```auto
int k=0; 
for (int rowNumber = 0; rowNumber < 6...{
   for (int colNumber = 0; colNumber < 8... {
       pieces[colNumber, rowNumber] = A[k];
       k++;
   }
}

```

For a similar shuffle example see [Can someone help me with this game? - #4 by Chrisir](https://discourse.processing.org/t/can-someone-help-me-with-this-game/28147/4)

Hey, and welcome to the forum!

Great to have you here!

Warm regards,

Chrisir

---

_[View the full topic](https://discourse.processing.org/t/arranging-objects-in-random-rows-and-columns/28163)._
