<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def survey(network=None, path='', pattern='', log=False):
 """ Search network for hosts with a response to path that matches pattern `network` - IP address and subnet mask compatible with [ipaddress library](https://docs.python.org/3/library/ipaddress.html#ipaddress.ip_network) `path` - Path portion of a URL as defined by [url(un)split](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlsplit) `pattern` - A regular expression pattern compatible with [re.compile](https://docs.python.org/3/library/re.html#re.compile) `log` - boolean to control logging level """

    if log:
        logger.setLevel(logging.DEBUG)
    else:
        logger.setLevel(logging.CRITICAL)

    network_scan = asyncio.ensure_future(asynchronous(
        urls=url_generator(network=network, path=path),
        re_filter=re.compile(pattern))
        )
    ioloop = asyncio.get_event_loop()
    ioloop.run_until_complete(network_scan)
    # Zero-sleep to allow underlying connections to close
    # http://aiohttp.readthedocs.io/en/stable/client_advanced.html#graceful-shutdown
    ioloop.run_until_complete(asyncio.sleep(0))
    # ioloop.close()  # don't close the loop, so it's available for re-use 
    # https://stackoverflow.com/questions/45010178/how-to-use-asyncio-event-loop-in-library-function
    return sorted(network_scan.result(), key=lambda x: ipaddress.ip_address(x.hostname))