import operator


def sorted_dict_items(d, reverse=False):
    """Sorted (key, value) pairs by value.
    """
    result = sorted(d.items(), key=operator.itemgetter(1))
    if reverse:
        return result[::-1]
    else:
        return result