World sorting by 'y' in update

I am working on a topdown rpg and I would like to know if there is any way to sort the elements on the map dynamically on each update.
For example, if the player’s y-axis is less than the y-axis of a tree, display the tree in front, otherwise display the player in the back.

group.sort('y', Phaser.Group.SORT_ASCENDING);

groups/depth sort

thanks