from typing import OrderedDict


def update_sort(sort, backwards):
    """update sort

    >>> update_sort([('a', 1), ('b': -1)], True)
    OrderedDict([('a', -1), ('b': -1), ('_id': -1)])
    """

    # change sort to OrderedDict
    sort = OrderedDict(sort)

    # Add _id to sort's keys
    # _id must be the last condiction of sort and ensure that position is unique.
    if '_id' not in sort.keys():
        sort['_id'] = 1

    # Reverse direction of sort if necessary
    if backwards:
        for i in sort:
            sort[i] = -sort[i]

    return sort