def bubblesort(arr):
      # Swap the elements to arrange in order
         for iter_num in range(len(arr)-1,0,-1):
            for idx in range(iter_num):
               if arr[idx]>arr[idx+1]:
                  temp = arr[idx]
                  arr[idx] = arr[idx+1]
                  arr[idx+1] = temp
      arr= [45,89,56,78,90,12,10,2,34,1]
      bubblesort(arr)
      print(arr)
      
      Python language logo

      Bubble Sort

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.