Created
August 20, 2020 00:41
-
-
Save kylelambert101/b4f96e613de652559f50625d87cadbe7 to your computer and use it in GitHub Desktop.
JavaScript -> Sort a list of objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myList = [ | |
{ title: "First one", link: "https://en.wikipedia.org" }, | |
{ title: "Second One", link: "https://en.wikipedia.org" }, | |
{ title: "Actual First One", link: "https://en.wikipedia.org" }, | |
]; | |
// Sort the list by {each}.title, alphabetically | |
const sortedList = myList.sort((a, b) => (a.title > b.title ? 1 : -1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment