Okay that was a good hint about the top level event. Both the text creation function call and the z ordering where inside the on selection changed event of the list object.
Now I have a top level trigger_order_z check that will order z when it's 1 and set itself to 0 afterwards. Works perfectly now. Thanks.
Edit: Got it even simpler. Now I made an On Text created -> order z event. So I do not need to trigger or use variables at all.
Edit 2: On Text created won't work. Don't know why. Guess I have to trigger variables..
Okay I did some testing. The only way I got it working correctly while still being automated without me needing to manually trigger the z ordering was as follows:
When I used z ordering inside the On Text created event it just did not order any text at all. Even when wait was used. So I need to trigger a variable and in the following event I can order z. I guess it has to do with something like On Text created it can not access instance variables yet.
When using the Sort event the first time the text is created will appear on the bottom of the layer for no reason. The second and following times the class is changed it works as inteded. Just the first time the class icon will not appear because z index will be below the character frame.
Anyway. The way I sat it up in the screenshot works.