Layering Instantiated UI elements in Hierarchy

I have UI elements that are spawned in and range from 3 - 8 different UI elements. These need to be in a specific order in the Hierarchy so they are layered correctly. How do i rearrange the Hierarchy in game so that the elements appear in correct order.


Im guessing this cant be done or no one really knows how to do it? The only way I can think of is have a layering system of empty gameobjects and spawn the UI i need in that layer to that gameobject. I was hoping for a cleaner solution

There are a few functions in Transform which let you change the order via code: