input: Write a function to sort a list of numbers using an optimized version of Bubble Sort.
  assert optimizedBubbleSort([7, 4, 5, 2, 9, 6])==[2, 4, 5, 6, 7, 9]
  assert optimizedBubbleSort([10, 3, 8, 15, 6, 1])==[1, 3, 6, 8, 10, 15]
  assert optimizedBubbleSort([5, 7, 9, 8, 6, 4, 3])==[3, 4, 5, 6, 7, 8, 9]
output: def optimizedBubbleSort(arr):
      n = len(arr)
      for i in range(n):
          swapped = False
          for j in range(0, n-i-1):
              if arr[j] > arr[j+1]:
                  arr[j], arr[j+1] = arr[j+1], arr[j]
                  swapped = True
          if not swapped:
              break
      return arr