Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def selection_sort(arr):
- for i in range(1, len(arr)):
- v = arr[i]
- j = i
- while j >= 1 and arr[j-1] > v:
- arr[j] = arr[j-1]
- j -= 1
- arr[j] = v
- # Example usage:
- arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]
- selection_sort(arr)
- print(arr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement