Last active
December 17, 2015 19:50
-
-
Save ehsania/5663614 to your computer and use it in GitHub Desktop.
Very simple implementation of "Insertion sort" in python
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(lst): | |
for i in xrange(1,len(lst)): | |
for j in xrange(0,i): | |
if lst[i] < lst[j]: | |
lst[i], lst[j] = lst[j], lst[i] | |
return lst |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment