Adjust sprite render order

I make 2D game. It’s something like top-side view. Like in “Nuclear Throne” or “Necrodancer” for example. And I need to adjust sprites order. I think I better explain with these screenshots:



The first picture is fine. And it’s what I need. But when I walk my hero on the other side, I get the second picture. But I need right order everytime. Lower sprites should be always rendered above the upper sprites. How can I do this?