You create an instance variable for the objects you want to sort.
When you want to sort them, pick them, and set the variable to their y value.
You then use the sort z order in the same event using that variable.
This will sort all those instances by their respective y values.
If you have diferent objects, place them in a family, and create a family variable.