mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-22 16:31:15 -04:00
Update insertion_sort.py
This commit is contained in:
parent
bcc9398a27
commit
1f23338150
1 changed files with 5 additions and 5 deletions
|
@ -1,13 +1,13 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# author: bt3gl
|
||||
|
||||
def insertion_sort(lst):
|
||||
|
||||
for i in range(1, len(lst)):
|
||||
def insertion_sort(array):
|
||||
|
||||
for i in range(1, len(array)):
|
||||
current_index = i
|
||||
|
||||
while current_index > 0 and lst[current_index - 1] > lst[current_index]:
|
||||
while current_index > 0 and array[current_index - 1] > array[current_index]:
|
||||
|
||||
lst[current_index], lst[current_index - 1] = lst[current_index - 1], lst[current_index]
|
||||
array[current_index], array[current_index - 1] = array[current_index - 1], array[current_index]
|
||||
current_index -= 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue