Distance sorting halving issue