def selection_sort(unsorted_arr):
          for idx in range(len(unsorted_arr)):
              min_idx = idx
              for j in range( idx +1, len(unsorted_arr)):
                  if unsorted_arr[min_idx] > unsorted_arr[j]:
                      min_idx = j
      # Swap the minimum value with the compared value
              unsorted_arr[idx], unsorted_arr[min_idx] = unsorted_arr[min_idx], unsorted_arr[idx]
      arr= [45,89,56,78,90,12,10,2,34,1]
      selection_sort(arr)
      print(arr)
      

      Python language logo
      Selection Sort

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.