Skip to content

Instantly share code, notes, and snippets.

@harveychurch
Last active June 5, 2020 18:45
Show Gist options
  • Save harveychurch/558a43e8e7054598dec1ad751cae8ac6 to your computer and use it in GitHub Desktop.
Save harveychurch/558a43e8e7054598dec1ad751cae8ac6 to your computer and use it in GitHub Desktop.
Sorting Algorigthm: "Something Sort". This is not efficient.
def somethingSort(array):
pointer = 0
number_of_comparisons = 0
while pointer < len(array)-1:
if array[pointer] > array[pointer+1]:
array[pointer+1],array[pointer] = array[pointer],array[pointer+1]
pointer = 0
else:
pointer += 1
number_of_comparisons += 1
return array,number_of_comparisons
This was an experiment whilst reteaching myself sorting algorithms in preperation for interviews.
It is no means efficient or smart, but a mistake that led to an interesting observation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment