''' Created on 2017-1-6 @author: admin ''' def bubbleSort(source): for i in reversed(range(len(source))): for j in reversed(range(len(source)-i,len(source))): if source[j]<source[j-1]: tmp=source[j-1] source[j-1]=source[j] source[j]=tmp if __name__ == '__main__': source=[3,1,9,8,6,7,5,4] bubbleSort(source) for i in range(0,len(source)): print(source[i],end=',')