school

thing1's amazing school repo
Log | Files | Refs | Submodules | README

bubble.py (443B)


      1 import sys
      2 
      3 
      4 def sort(list):
      5     length = len(list)
      6     for i in range(length - 1):
      7         for j in range(length - i - 1):
      8             if list[j] > list[j+1]:
      9                 tmp = list[j]
     10                 list[j] = list[j+1]
     11                 list[j+1] = tmp
     12     return list
     13 
     14 
     15 if __name__ == "__main__":
     16     count = int(sys.argv[1])
     17 
     18     num = []
     19     for i in range(count):
     20         num.append(int(input(f"number {i}: ")))
     21 
     22     print(sort(num))