Skip to content

Instantly share code, notes, and snippets.

@anonymousmaharaj
Created March 15, 2021 20:22
Show Gist options
  • Save anonymousmaharaj/efef6090c52ba8888b4f3a291a13aa55 to your computer and use it in GitHub Desktop.
Save anonymousmaharaj/efef6090c52ba8888b4f3a291a13aa55 to your computer and use it in GitHub Desktop.
import main
def findsmaller(arr):
smallest = arr[0]
smallest_index = 0
for i in range(1,len(arr)):
if arr[i]< smallest:
smallest=arr[i]
smallest_index = i
return smallest_index
def selectionSort(arr):
newArr = []
for i in range(len(arr)):
smallest = findsmaller(arr)
newArr.append(arr.pop(smallest))
return newArr
list = [3,5,1,5,7 ,8 ,9 ,3 ,4 ,5,0,-3]
print(selectionSort(list))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment