SitePoint Quick Tip: How to Sort an Array of Objects in JavaScript If you have an array of objects that you need to sort into a certain order, the temptation might be to reach for a JavaScript library. Before you do however, rember that you can do some pretty neat sorting with the native Array.sort function. In this article I'll show you how to sort an array of objects in JavaScript with no fuss or bother. To follow along with this article, you will need a knowledge of basic JavaScript concepts, such as declaring variables, writing functions, and conditional statements. I'll also be using ES6 syntax. You can get a refresher on that here: https://www.sitepoint.com/tag/es6/ Basic Array Sorting By default, the JavaScript Array.sort function converts each element in the array to be sorted, into a string, and compares them in Unicode code point order. const foo = [9, 2, 3, 'random', 'panda']; foo.sort(); // returns [ 2, 3, 9, 'panda', 'r