Best practice for managing sprite draw order?

Hey all, I’m working on a 2/3 perspective game (think Don’t Starve) and I’m wondering what the best method would be for managing the draw order of sprites? My naive solution would be just set their z-index to match their y position, but then you’re limited to a world size of 65534x65534 pixels which might be enough, but I feel like there must be a more elegant solution out there. Any thoughts?

You should only need to map the visible range to the z-index as everything outside of that isn’t visible. That would make the range 240 + your biggest sprite (for partially visible sprites).

Is there a way to iterate over just the visible sprites , or would I have to set every sprite every frame based on their offset?