input: Write a function to calculate the mean and median of a given array. Remember to consider cases where the length of the array is odd or even. If the array is empty, return None for both the mean and median.
  assert mean_median([10, 15, 20, 25, 30, 35]) == (22.5, 22.5)
  assert mean_median([1, 2, 3, 4, 5]) == (3, 3)
  assert mean_median([4, 8, 15, 16, 23, 42]) == (18, 15.5)
  assert mean_median([]) == (None, None)
  assert mean_median([1]) == (1, 1)
output: def mean_median(arr):
      if not arr:
          return None, None
      arr.sort()
      n = len(arr)
      mean = sum(arr) / n
      if n % 2 == 1:
          median = arr[n // 2]
      else:
          median = (arr[n // 2 - 1] + arr[n // 2]) / 2
      return mean, median