def _move_ordered_dict_item(o_dict, item_key, new_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
Move an item in an ordered dictionary to a new position
dataset/ETHPy150Open rproepp/spykeviewer/spykeviewer/plugin_framework/filter_manager.py/_move_ordered_dict_item