Python Program to Implement Selection Sort

In this program, we will implement selection sort algorithm

  1. #Python program to implement Selection sort
  2. def selection_sort(a):
  3. for i in range(0, len(a) - 1):
  4. first = i
  5. for j in range(i + 1, len(a)):
  6. if a[j] < a[first]:
  7. first = j
  8. a[i], a[first] = a[first], a[i]
  9. a = input(&#x27;Enter list elements: &#x27;).split()
  10. a = [int(x) for x in a]
  11. selection_sort(a)
  12. print(&#x27;Sorted list: &#x27;, end=&#x27;&#x27;)
  13. print(a)

Output! is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube