File size: 445 Bytes
6dfe4cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import time
from colors import *


def insertion_sort(data, draw_data, time_tick):
    for i in range(len(data)):
        temp = data[i]
        j = i
        while j > 0 and temp < data[j-1]:
            data[j] = data[j-1]
            j -= 1
        data[j] = temp
        draw_data(data, [LIGHT_GREEN if x == j or x == i else BLUE for x in range(len(data))])
        time.sleep(time_tick)
    draw_data(data, [BLUE for x in range(len(data))])