Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def max_sort(arr, last_index):
- if last_index == 0:
- return arr
- max_ = arr[0]
- max_index = 0
- for i in range(1, last_index+1):
- if arr[i] > max_:
- max_ = arr[i]
- max_index = i
- temp = arr[last_index]
- arr[last_index] = arr[max_index]
- arr[max_index] = temp
- arr = max_sort(arr, last_index-1)
- return arr
- print(max_sort([5, 4, 3, 2, 1], 4))
- print(max_sort([10, 9, 8, 3, 4, 5, 6, 7, 2, 1], 9))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement