TD4_DEV51_Qualite_Algo/tri.py

16 lines
422 B
Python
Raw Permalink Normal View History

2024-11-26 11:23:20 +01:00
def tri(t):
for tab in t:
2024-11-26 11:31:30 +01:00
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]
2024-11-26 11:23:20 +01:00
for i in range(len(t)):
2024-11-26 11:31:30 +01:00
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]
2024-11-26 11:23:20 +01:00
print(t)
tri([[3, 9, 6], [9, 3, 8], [10, 67, 55]])