def fusionner(tab, indice_Debut, indice_Partage, indice_Fin): tab1 = [tab[i] for i in range (indice_Debut, indice_Partage+1)] tab2 = [tab[i] for i in range (indice_Partage+1, indice_Fin+1)] i, j = 0, 0 for k in range(indice_Debut, indice_Fin+1): if i >= len(tab1) or (j < len(tab2) and tab1[i] > tab2[j]): tab[k] = tab2[j] j = j + 1 else: tab[k] = tab1[i] i = i + 1 def tri_fusion(tab, indice_Debut, indice_Fin): """ trie par fusion la liste en paramètre depuis i_debut jusqu’à i_fin """ if indice_Debut < indice_Fin and indice_Debut >= 0 and indice_Fin < len(tab): indice_Partage = (indice_Debut + indice_Fin - 1) // 2 tri_fusion(tab, indice_Debut, indice_Partage) tri_fusion(tab, indice_Partage + 1, indice_Fin) fusionner(tab, indice_Debut, indice_Partage, indice_Fin)