Can I define my own depth sorting for the sprites when the perspective camera is used?

This is partly solved in the fragment shader by calling discard for transparent pixels. But this does not work well for opaque surfaces (like glass).

    vec4 color = texture2D(tex0, var_texcoord0.xy) * tint_pm;
    if(color.a < 0.3) discard;