# How can I arrange objects in order in the scene?

I have to import boxes with differents size and arrange them in a quadrant so that the larger ones are on one corner and the smaller ones on the opposite corner.

to make myself more understandable, here is a picture of where I have arrived until now

what i need to do is to sort the boxes by angles and not by lines or rows

Any reference picture of the result?

So this question is not about three.js specifically, but about sorting in general.

well actually it could be, do you have an idea anyway?

Will it always have 3 β0β, 3 β1β, 4 β2β, 5 β3β, 4 β4β, 3 β5β and 3 β6β ?

thanks for the answers, by the way,

it was just an example the boxes are created randomly, for example with a height value from 0 to 20. I should find a way to always allocate them in the right position. From the largest to the smallest, or vice versa, in order not by lines or rows on the dial, but more by radians.

So, basically, you want it in this order?

1 Like

YES! exactly like this

/cc

First, put bars in an array and sort it by heights of bars.
Second, find an algorithm that puts elements of an array in the desired order.

Well, with help of `.sort()` of array and this SO answer: https://stackoverflow.com/q/35373936/4045502
Iβve turned this

into this

2 Likes

Wow! thatβs exactly what I meant.

thanks a lot

Youβre welcome