Table of Contents

About

This example shows you how you can sort an array of objects with the sort function

Example

let colors = [
  { name: 'blue' },
  { name: 'red' },
  { name: 'purple' },
];
colors.sort((a, b) => a.name.localeCompare(b.name));
colors.forEach(c=>console.log(c.name));