How does new UI work?

I checked that new UI depth is managed by the order in hierarchy.

but here, what I want to know is that how it really works.

In my thinking There would be a few ways to sort each depth like “By managing z value” and “By managing shader’s render q”

Which way does new UI use?

You are correct: For children of canvas elements, Unity strictly uses the order in the hierarchy to determine the UI depth. You can change the ordering on the fly, using SetAsFirstSibling, SetAsLastSibling, and SetSiblingIndex.

If you need to override the hierarchical order entirely, you can place a new Canvas component on a GameObject, and set its Sort Order appropriately – with the understanding that this will generate a new draw-call for that sub-hierarchy, even if you’re entirely using sprites that are using the same Packing Tag as the sprites on your main Canvas. (Also, this approach can be buggy, sometimes. Test on-device, early and often.)