Last active
March 15, 2022 15:22
-
-
Save Thaekeh/2f4b4e96f9d8b1167e27ec17078cac75 to your computer and use it in GitHub Desktop.
Sort arrays alphabetically
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
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