from typing import OrderedDict


def sort_by_key(value, reverse=False):
    """
    sorts a dictionary by its keys.

    :param dict value: dict to be sorted.

    :param bool reverse: sort by descending order.
                         defaults to False if not provided.

    :rtype: OrderedDict
    """

    result = sorted(value.items(), key=lambda x: x[0], reverse=reverse)
    return OrderedDict(result)