Clasificación de inserción usando mientras está en Python
def insertion_sort(l: list):
"""sorts the input list using the insertion sort algorithm"""
index = 1
while index < len(l):
insertion_index = index
while insertion_index > 0 and l[insertion_index] < l[insertion_index - 1]:
# swap the two elements
element = l[insertion_index]
l[insertion_index] = l[insertion_index - 1]
l[insertion_index - 1] = element
insertion_index = insertion_index - 1
index = index + 1
Quaint Quoll