fork download
  1. # IDK what this thing is tbh but it should sort everything
  2. import math
  3. from random import random
  4. i=0
  5. a=[]
  6. while i<100 :
  7. a.append(round(100*random()))
  8. i=i+1
  9. print(a) # print our list to see the changes
  10. ''' a[0],a[1] = a[1],a[0]
  11. this is how you swap two items in a list btw '''
  12. for n in range(0,len(a)-1) :
  13. while not a[n]<=a[n+1] :
  14. for i in range(len(a)-1) :
  15. if a[i]>a[i+1] :
  16. a[i],a[i+1] = a[i+1],a[i]
  17. print(a)
Success #stdin #stdout 0.02s 11740KB
stdin
Standard input is empty
stdout
[72, 19, 19, 81, 90, 1, 79, 42, 48, 75, 38, 60, 8, 26, 83, 58, 70, 31, 5, 11, 30, 47, 90, 24, 25, 46, 65, 12, 13, 67, 56, 5, 91, 62, 60, 62, 23, 21, 63, 66, 23, 97, 96, 27, 85, 73, 65, 57, 9, 15, 33, 8, 16, 88, 39, 16, 56, 86, 92, 64, 59, 9, 59, 55, 14, 55, 58, 59, 71, 56, 95, 54, 17, 54, 21, 74, 95, 34, 21, 33, 42, 45, 81, 46, 24, 45, 89, 14, 8, 39, 68, 48, 39, 90, 14, 5, 41, 80, 15, 39]
[1, 5, 5, 8, 11, 12, 13, 19, 9, 15, 19, 8, 16, 21, 23, 16, 23, 24, 25, 26, 27, 9, 30, 31, 14, 33, 38, 39, 42, 46, 47, 48, 17, 54, 21, 54, 55, 34, 21, 33, 42, 45, 55, 46, 24, 45, 56, 14, 8, 39, 56, 48, 39, 56, 14, 5, 41, 57, 15, 39, 58, 58, 59, 59, 59, 60, 60, 62, 62, 63, 64, 65, 65, 66, 67, 68, 70, 71, 72, 73, 74, 75, 79, 80, 81, 81, 83, 85, 86, 88, 89, 90, 90, 90, 91, 92, 95, 95, 96, 97]