def _move_ordered_dict_item(o_dict, item_key, new_position):
    """ Move an item in an ordered dictionary to a new position

    :param OrderedDict o_dict: The dictionary on which the move takes place
    :param key item_key: The key of the item to move. If the key does not
        exist in the dictionary, this function will do nothing.
    :param key new_position: The item to move will be inserted after the
        item with this key. If this key does not exist in the dictionary,
        the item will be moved to the first position.
    """
    # Bad performance, use only on small dictionaries
    # and/or non time-critical places
    if not o_dict or not item_key in o_dict:
        return

    item = o_dict[item_key]
    items = o_dict.items()
    in_there = new_position in o_dict

    o_dict.clear()
    if not in_there:
        o_dict[item_key] = item

    for i in items:
        if i[0] != item_key:
            o_dict[i[0]] = i[1]
        if i[0] == new_position:
            o_dict[item_key] = item
dataset/ETHPy150Open rproepp/spykeviewer/spykeviewer/plugin_framework/filter_manager.py/_move_ordered_dict_item/original