Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def mybubble(array):
- sorted_array = [array[0]]
- for x in array[1:]:
- bigger_found = False
- for y in sorted_array:
- if x < y:
- sorted_array.insert(sorted_array.index(y),x)
- bigger_found = True
- break
- if not bigger_found:
- sorted_array.append(x)
- return sorted_array
- arr = [random.choice(range(50)) for i in range(20)]
- print(arr)
- sort_arr = mybubble(arr)
- print(sort_arr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement