def tri(t): for tab in t: for i in range(len(tab)): for j in range(len(tab) - 1): if tab[j] > tab[j + 1]: tab[j], tab[j + 1] = tab[j + 1], tab[j] for i in range(len(t)): for j in range(len(t) - 1): if t[j][0] > t[j + 1][0]: t[j], t[j + 1] = t[j + 1], t[j] print(t) tri([[3, 9, 6], [9, 3, 8], [10, 67, 55]])