Organize scrollview children dynamically

I have a basic vertical scroll view that dynamically sizes it’s Y value based on how many children are added per button click.

I have a template that is added in the hierarchy of
One of these text elements has a number being set as the text item. I am wanting to organize the children of the scrollview from greatest to least. How would I go about running this as the items in this scrollview change on user input?

Without knowing too much about your project and layout, the way I would do this is to use the layout group for the content and order the children in whatever order you need them to be.

I do something similar in layout here: Dynamic UI Scroll View | Learn PlayCanvas

And there are functions for adding children to an Entity that can help with order here: Entity | PlayCanvas API Reference