Skip to content

Instantly share code, notes, and snippets.

@sejr
Last active August 6, 2016 00:23
Show Gist options
  • Select an option

  • Save sejr/4cd0ed52d22a429ac37eecd192020651 to your computer and use it in GitHub Desktop.

Select an option

Save sejr/4cd0ed52d22a429ac37eecd192020651 to your computer and use it in GitHub Desktop.
# coding: utf-8
def find_position(i, array):
input_added = False
for index, value in enumerate(array):
if i < value:
array.insert(index, i)
input_added = True
return 1
if input_added == False:
array.append(i)
return 1
def dropsort(array):
print array
result = []
result.append(array[0])
array.pop(0)
for index, input in enumerate(array):
find_position(input, result)
return result
if __name__ == '__main__':
testA = [1, 4, 7, 17, 13, 8, 22]
testB = [7, 100, -628, -2, 381]
print dropsort(testA)
print dropsort(testB)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment