import io
import yaml


def dict_to_yaml(data, width=None, sort=False):
    """ Convert dictionary into yaml """
    output = io.StringIO()
    yaml.safe_dump(
        data, output, sort_keys=sort,
        encoding='utf-8', allow_unicode=True,
        width=width, indent=4, default_flow_style=False)
    return output.getvalue()