|
|
@ -7,4 +7,13 @@ def tri_selection(liste): |
|
|
# On cherche le plus petit élément dans le reste de la liste |
|
|
# On cherche le plus petit élément dans le reste de la liste |
|
|
for j in range(i + 1, n): |
|
|
for j in range(i + 1, n): |
|
|
if liste[j] < liste[indice_min]: |
|
|
if liste[j] < liste[indice_min]: |
|
|
indice_min = j |
|
|
indice_min = j |
|
|
|
|
|
# On échange les éléments |
|
|
|
|
|
liste[i], liste[indice_min] = liste[indice_min], liste[i] |
|
|
|
|
|
|
|
|
|
|
|
return liste |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Exemple d'utilisation |
|
|
|
|
|
ma_liste = [64, 25, 12, 22, 11] |
|
|
|
|
|
print(tri_selection(ma_liste)) |