Methods for working with arrays in JavaScript

You can also sort an array of object by providing a comparator function Please note that sort() method sorts the elements of an array in ascending order by default, so if you want to sort it in descending order you need to provide a comparator function.