Python插入排序和冒泡排序

2019-04-14 13:05发布

#!/usr/bin/python def insert_sort(l=[]):     l = l     n = len(l)     for i in range(1,n):         tmp = l[i]         j   = i - 1         while j>=0 and tmpl[j+1]:                 l[j] = l[j+1]                 l[j+1]=tmp                 #j = j+1         #n = n-1     return l def main():     l = [101,9,8,10,5,3,100]     print bubble_sort(l) if __name__ == "__main__":     main()