input: Write a python function to rearrange an array such that the most common element is swapped with the middle element.
  assert medianMostCommon([4, 5, 2, 5, 8, 5, 6, 5]) == [4, 5, 5, 5, 5, 6, 8, 2]
  assert medianMostCommon([1, 2, 2, 3, 4, 2, 5]) == [1, 2, 2, 2, 4, 3, 5]
  assert medianMostCommon([9, 1, 9, 9, 9, 6, 7, 8, 9]) == [9, 1, 9, 9, 9, 6, 7, 8, 9]
  assert medianMostCommon([1, 1, 2, 2, 3, 3]) == [1, 1, 3, 2, 2, 3]
output: def medianMostCommon(arr):
      from collections import Counter
      
      if not arr:
          return arr
  
      # Find the most common element
      counter = Counter(arr)
      most_common_element = counter.most_common(1)[0][0]
  
      # Find the index of the middle element
      n = len(arr)
      middle_index = n // 2
      
      # Swap the most common element with the middle element
      for i in range(n):
          if arr[i] == most_common_element:
              arr[i], arr[middle_index] = arr[middle_index], arr[i]
              break
  
      return arr