tpl = [(10, 7), (4, 9), (13, 4), (7, 13), (9, 10)]
start_dict = {item[0]: item for item in tpl}
start = tpl[0][0]
res = []
while start_dict:
    item = start_dict[start]
del start_dict[start]
res.append(item)
start = item[-1]
print(res)
Sort a list of tuples in consecutive order