Created
December 2, 2020 13:23
-
-
Save Thaekeh/eab4e8e392d87463b332b840eea7d2d6 to your computer and use it in GitHub Desktop.
Sort an array by a Boolean value.
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: { | |
sortedRecipes() { | |
tempArray = tempArray.sort((a, b) => { | |
if (a.favorite && !b.favorite) { | |
return -1 | |
} else if (!a.favorite && b.favorite) { | |
return 1 | |
} else { | |
return 0 | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment