var objects = [{'Name': 'John', 'Age': 23, 'Profession': 'Accountant'}, {'Name': 'Adam', 'Age': 18, 'Profession': 'Engineer'}, {'Name': 'Vik', 'Age': 46, 'Profession': 'Architect'}, {'Name': 'Jane', 'Age': 36, 'Profession': 'Developer'}, {'Name': 'Rikky', 'Age': 28, 'Profession': 'Developer'}];The following function call sorts the array by 'Profession' then by 'Name' descendantly
sortBy(objects, 'Profession', {'Name': 'desc'}); console.table(objects);The result will be the following:
Now let's have a look at the method implementation.