Algorithme complet
stableInsérer l'élément courant dans la partie gauche déjà triée.
element = tableau[indice]Élément à placer
while tableau[j-1] > elementDécalage (strict >)
tableau[position] = elementInsertion finale
def tri_insertion(tableau):
nb_elements = len(tableau)
for indice in range(1, nb_elements):
element_a_inserer = tableau[indice]
position = indice
while position > 0 and tableau[position - 1] > element_a_inserer:
tableau[position] = tableau[position - 1]
position = position - 1
tableau[position] = element_a_inserer