Sort an array of composite structures

FCC link

Write a function that takes an array of objects as a parameter. The function should sort the array according to the 'key' attribute of the objects and return the sorted array.

Test

{{test}}

Console output