Sort on distance ($l)