Ordering points by distance