You don't, at least not for writes. Z-buffer writing/ordering and transparency is not really something you can do easily. Most techniques require significantly more work than you're likely prepared for, like using depth peeling.
Sort your objects. Typically you would sort opaque (or alpha cutout) objects front-to-back with Z-buffering enabled, then do a second pass of any translucent objects sorted back-to-front with Z-buffer writes disabled (but Z-testing still enabled!). Doing the opaque front-to-back typically helps performance when you have a lot of overdraw (overlapping objects/sprites) by avoiding drawing the same pixel fragment more than once.
The problem with Z-buffering is that there is no way for the Z-buffer to both know what the closest opaque (occluding) pixel is (in a hardware-friendly way, at least), and even if it could, transparency order matters for some blending modes. If you blend A onto B you will get a different color than if you blend B onto A in many common blending modes. You must sort the objects to get the correct output, with or without Z-buffering issues. You also need to draw the opaque objects first to blend over them.
Larger 3D engines typically handle this by having multiple render queues that sort and batch objects separately. Opaque objects can end up in one queue with Z-buffering on, and maybe with front-to-back sorting on. Translucent order-dependent objects end up in a different queue with Z writes off but reads on (you don't want to blend in translucent objects that are behind the opaque scenery!). Translucent order-independent objects (additive-blending particles most often) can be put in yet another queue with no sorting at all, Z-writes off (Z-reads still on). You can also have multiple render queues for things like UI overlays and such.