Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eclectic-coding/a89e4a52285e7a7317a5292590bbb533 to your computer and use it in GitHub Desktop.
Save eclectic-coding/a89e4a52285e7a7317a5292590bbb533 to your computer and use it in GitHub Desktop.
Sort arrays alphabetically
computed: {
sortedArray() {
let sortedRecipes = this.recipes;
sortedRecipes = sortedRecipes.sort((a,b) => {
let fa = a.title.toLowerCase(), fb = b.title.toLowerCase();
if (fa < fb) {
return -1
}
if (fa > fb) {
return 1
}
return 0
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment