def bubbleSort(nums): i = len(nums) - 1 while (i > 0): last_index = 0 for j in range(i): if nums[j] > nums[j+1]: nums[j],nums[j+1] = nums[j+1],nums[j] last_index = j i = last_index return nums