def bubble_sort(nums):
n = len(nums)
for i in range(n):
swapped = False
for j in range(1, n - i):
if nums[j] < nums[j - 1]:
nums[j], nums[j - 1] = nums[j - 1], nums[j]
swapped = True
if not swapped: break
return nums
print(bubble_sort([9, 8, 7, 6, 5, 4, 3, 2, 1]))