Collisions and Gravity and Arrays oh my!

Help request, yet again!

Part A:
I am making a site where there are 40 names. After clicking on a name, id like the other 39 to collapse to the bottom of the screen.

Then, as those 39 are falling, have them detect collision so they stack on top of each other, not just collapse.

Part B.

I need each of those remaining 39 to act as buttons, where clicking on one will bring it back up (reverse gravity) and then bring the other one to the bottom, so that there is only 1 name not at the bottom at a time.

Part C.

I need each of those names and that up/down action to be selectable with a next/prev action too.

So far, i have the gravity working, all the names collapse. So i just need help with the collision detection and transitions between.


oh, and the “arrays” part, was because i was wondering if that would be easier to manage 40 names w/ an array instead of having to name each of them, etc.