Dump object to a file like object or string.

    :param obj:
    :param fp: Open file like object
    :param int indent: Indent size, default 2
    :param bool sort_keys: Optionally sort dictionary keys.
    :return: Yaml serialized data.

def dump(obj, fp=None, indent=None, sort_keys=False, **kw):
    """
    Dump object to a file like object or string.

    :param obj:
    :param fp: Open file like object
    :param int indent: Indent size, default 2
    :param bool sort_keys: Optionally sort dictionary keys.
    :return: Yaml serialized data.
    """

    if fp:
        iterable = YAMLEncoder(indent=indent, sort_keys=sort_keys, **kw).iterencode(obj)
        for chunk in iterable:
            fp.write(chunk)
    else:
        return dumps(obj, indent=indent, sort_keys=sort_keys, **kw)