Last active
January 9, 2017 23:24
-
-
Save multivac61/844d95f5c8b4ef6e3938 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def insertion_sort(m, sort_by=(lambda a, b: a < b)): | |
def insert_item(m, item0): | |
for i, item in enumerate(m): | |
if sort_by(item0, item): | |
m.insert(i, item0) | |
return | |
m.append(item0) | |
if len(l) <= 1: | |
return l | |
sorted_list = [] | |
for item in l: | |
insert_item(sorted_list, item) | |
return sorted_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should be 'm', instead of 'l' for lines 9 and 10.