input: Write a python function to sort an array of objects based on a given key.
  assert sortObjectArray([{"name": "John", "age": 26}, {"name": "Alice", "age": 30}, {"name": "Bob", "age": 22}], 'age') == [{"name": "Bob", "age": 22}, {"name": "John", "age": 26}, {"name": "Alice", "age": 30}]
  assert sortObjectArray([{"name": "John", "age": 40}, {"name": "Alice", "age": 25}, {"name": "Bob", "age": 30}], 'name') == [{"name": "Alice", "age": 25}, {"name": "Bob", "age": 30}, {"name": "John", "age": 40}]
  assert sortObjectArray([{"name": "John", "age": 20}, {"name": "John", "age": 18}, {"name": "John", "age": 25}], 'age') == [{"name": "John", "age": 18}, {"name": "John", "age": 20}, {"name": "John", "age": 25}]
output: def sortObjectArray(arr, key):
      return sorted(arr, key=lambda x: x[key])