Code written using tabnine and python

def insertion_sort(list):

    for i in range(1, len(list)):
        item_insert = list[i]

        j = i - 1

        while j >= 0 and list[j] > item_insert:
            list[j + 1] = list[j]
            j -= 1
        # Insert the item
        list[j + 1] = item_insert

anylist = [2,5,6,8,1,0]
insertion_sort(anylist)
print(anylist)

Built With

Share this project:

Updates

Submission history