Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. import random
  2.  
  3. def bubbles_sort(sample):
  4.     n = 1
  5.     while n < len(sample):
  6.         for i in range(len(sample) - n):
  7.             if sample[i] > sample[i+1]:
  8.                 sample[i], sample[i+1] = sample[i+1], sample[i]
  9.        
  10.         n += 1
  11.     return sample
  12.    
  13. sample = [random.randrange(10) for i in range(10)]
  14.  
  15. print(bubbles_sort(sample))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement