Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def bubbles_sort(sample):
- n = 1
- while n < len(sample):
- for i in range(len(sample) - n):
- if sample[i] > sample[i+1]:
- sample[i], sample[i+1] = sample[i+1], sample[i]
- n += 1
- return sample
- sample = [random.randrange(10) for i in range(10)]
- print(bubbles_sort(sample))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement