Implement sorted distances for better corridor connections