Y-sorting
Draw order in top-down games is decided by each object's y-coordinate, so things lower on screen overlap the least.
In 2D and 2.5D games viewed at an angle from above there is no depth to test against. The fix is to sort sprites by their y-position every frame and draw them top to bottom: a character whose feet sit lower on screen is closer to the camera and is drawn last, on top of everything behind. A cousin of the painter's algorithm, but keyed on a single axis.
Pitfalls appear with tall or overlapping objects — a tree and a player behind it can "swap places" depending on which pixel is compared. The usual fix is to sort on a fixed anchor point at the object's base.