blob: d92ed2ef0f12f670c1f15eed46f88599e2283480 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
def shell_sort(my_list):
gap = len(my_list) // 2
while gap > 0:
for i in range(gap, len(my_list)):
current_item = my_list[i]
j = i
while j >= gap and my_list[j - gap] > current_item:
my_list[j] = my_list[j - gap]
j -= gap
my_list[j] = current_item
gap //= 2
return my_list
|