Day 229: why don't use a depth buffer instead of sorting?

At day 229 we sort the render elements before rendering them in order, but could we use a depth buffer with the sort key as the depth value? This would take some more memory but isn't this more efficient, instead of sorting all the render elements?

Edited by Terans on Reason: Initial post
The sprites have alpha transparency, so they need to be rendered back-to-front in order to get alpha blending. Imagine you draw a transparent portion of a sprite with the depth buffer, then you draw another sprite behind it. The sprite in back should be visible, but it won't be drawn because it fails the depth test. This page has some good visual examples of what that looks like: https://learnopengl.com/Advanced-OpenGL/Blending