Skip to content

Instantly share code, notes, and snippets.

@shameemreza
Created June 5, 2018 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shameemreza/ffc6ef341edac03e514b66d5918a425f to your computer and use it in GitHub Desktop.
Save shameemreza/ffc6ef341edac03e514b66d5918a425f to your computer and use it in GitHub Desktop.
# Python program for implementation of Selection
# Sort
import sys
A = [64, 25, 12, 22, 11]
# Traverse through all array elements
for i in range(len(A)):
# Find the minimum element in remaining
# unsorted array
min_idx = i
for j in range(i+1, len(A)):
if A[min_idx] > A[j]:
min_idx = j
# Swap the found minimum element with
# the first element
A[i], A[min_idx] = A[min_idx], A[i]
# Driver code to test above
print ("Sorted array")
for i in range(len(A)):
print("%d" %A[i]),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment