21. Give a list of pure numbers. Please sort the list (upgrade question).
Ideas:
(1) Complete the data exchange between A and B. For example, a = ten, B = 24 after exchange, A = 10, B =
(2) Loop list. Determine the size relationship between A[i] and a[i+1], if a[i] is larger than a[i+1. Then swap. At the end of the cycle. The largest data in the current list is moved to the far right.
(3) Think about it if you perform the above operation again. Finally, the second-largest data is moved to the right. And so on. If you perform the appropriate action repeatedly. Then the list becomes an ordered list.
lst = [88,5,8,6,1,23] for n in range (len (LST) -1 = 0 while i < len (LST) -1: if lst[i]>lst[i+1]: lst[i],lst[i +1] = Lst[i+1],lst[i] # print (i) i+=1print (LST)
New_li == [88,55,33,66,11,22] while Len (LST): new_li.append min (lst ) Print (New_li) lst.remove (min (LST))
Python3.6 full Stack Development example [021]