Bubble Sort

Given an array of integers, sort the elements in the array in ascending order. The bubble sort algorithm should be used to solve this problem.

def bubble(array):
  for n in xrange(len(array)-1,0,-1):
    for i in xrange(n):
      if array[i] > array[i+1]:
        array[i],array[i+1] = array[i+1],array[i]

你可能感兴趣的:(Bubble Sort)