input = [(10, 7), (4, 9), (13, 4), (7, 13), (9, 10)]
input_dict = dict(input)
elem = input[0][0]
new_list = []
for _ in range(len(input)):
    new_list.append((elem, input_dict[elem]))
elem = input_dict[elem]
if elem not in input_dict:
    raise Exception('key {} not found in dict'.format(elem))
Сортировка списка кортежей в последовательном порядке