def compare_settings(local_config_vars, remote_config_vars):
    """Compare local and remote settings and return the diff.

    This function takes two dictionaries, and compares the two. Any given
    setting will have one of the following statuses:

    '=' In both, and same value for both (no action required)
    '!' In both, but with different values (an 'update' to a known setting)
    '+' [In local, but not in remote (a 'new' setting to be applied)
    '?' In remote, but not in local (reference only - these are generally
        Heroku add-on specfic settings that do not need to be captured
        locally; they are managed through the Heroku CLI / website.)

    NB This function will convert all local settings values to strings
    before comparing - as the environment settings on Heroku are string.
    This means that, e.g. if a bool setting is 'true' on Heroku and True
    locally, they will **not** match.

    Returns a list of 4-tuples that contains:

        (setting name, local value, remote value, status)

    The status value is one of '=', '!', '+', '?', as described above.

    """
    diff = []
    for k, v in local_config_vars.items():
        if k in remote_config_vars:
            if str(remote_config_vars[k]) == str(v):
                diff.append((k, v, remote_config_vars[k], '='))
            else:
                diff.append((k, v, remote_config_vars[k], '!'))
        else:
            diff.append((k, v, None, '+'))

    # that's the local settings done - now for the remote settings.
    for k, v in remote_config_vars.items():
        if k not in local_config_vars:
            diff.append((k, None, v, '?'))

    return sorted(diff)