Skip to content

Instantly share code, notes, and snippets.

@gbols
Created October 20, 2019 07:34
Show Gist options
  • Save gbols/b81ed7f5b5ada27b69ea0aee575e2807 to your computer and use it in GitHub Desktop.
Save gbols/b81ed7f5b5ada27b69ea0aee575e2807 to your computer and use it in GitHub Desktop.
Chaser
const users = [
{
name: "matt sanders",
rank: 5
},
{
name: "winifred bony",
rank: 2
},
{
name: "gbolahan olagunju",
rank: 1
}
]
const sortedbyRank = users.sort((a, b) => b.rank < a.rank);
console.log(sortedbyRank)
const sortedbyName = users.sort((a, b) => b.name < a.name);
console.log(sortedbyName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment