Repository where I mostly put random python scripts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
278 B

  1. #selection sorting
  2. import sys
  3. A = [6, 2, 1, 3, 4]
  4. for i in range(len(A)):
  5. min_index = i
  6. for j in range(i+1, len(A)):
  7. if A[min_index] > A[j]:
  8. min_index = j
  9. A[i], A[min_index] = A[min_index], A[i]
  10. print ("Sorted array")
  11. for i in range(len(A)):
  12. print("%d" %A[i])