<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def list_snapshots(config_path=_DEFAULT_CONFIG_PATH, sort_by_time=False):
    '''
    Get a list of all the existing snapshots.

    :param str config_path: The path to the configuration file for the aptly instance.
    :param bool sort_by_time: Whether to sort by creation time instead of by name.

    :return: A list of the snapshot names.
    :rtype: list

    CLI Example:

    .. code-block:: bash

        salt '*' aptly.list_snapshots
    '''
    _validate_config(config_path)

    cmd = ['snapshot', 'list', '-config={}'.format(config_path), '-raw=true']

    if sort_by_time:
        cmd.append('-sort=time')
    else:
        cmd.append('-sort=name')

    cmd_ret = _cmd_run(cmd)
    ret = [line.strip() for line in cmd_ret.splitlines()]

    log.debug('Found snapshots: %s', len(ret))
    return ret