|
1234567891011121314151617181920 |
-
- def pop_sort(lst):
- for i in range(len(lst)-1, 0, -1):
- move_max(lst, i)
-
-
- def move_max(lst, max_index):
- for i in range(max_index):
- if lst[i] > lst[i+1]:
- lst[i], lst[i+1] = lst[i+1], lst[i]
-
- if __name__ == '__main__':
- lst = [4, 1, 7, 2, 3, 6]
- # pop_sort(lst)
- # print(lst)
- for j in range(len(lst) - 1, 0, -1):
- for i in j:
- if lst[i] > lst[i+1]:
- lst[i], lst[i+1] = lst[i+1], lst[i]
-
|