You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
574 B
19 lines
574 B
def tri_selection(liste):
|
|
n = len(liste)
|
|
|
|
for i in range(n):
|
|
# On suppose que le minimum est au début
|
|
indice_min = i
|
|
# On cherche le plus petit élément dans le reste de la liste
|
|
for j in range(i + 1, n):
|
|
if liste[j] < liste[indice_min]:
|
|
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))
|