冒泡排序
1 # #!usr/bin/env python 2 # #-*- coding=utf-8 -*- 3 list1 = [11,22,3,4,565,77]#定义列表 4 for j in range(1,len(list1)):#循环len-1次 5 for i in range(len(list1)-1): 6 if list1[i] > list1[i+1]:#从小到大(大于变成小于就是从大到小) 7 temp = list1[i+1] 8 list1[i+1] = list1[i] 9 list1[i] = temp 10 newlist = list1 11 print (newlist)