Skip to content

Instantly share code, notes, and snippets.

@Thaekeh
Created December 2, 2020 13:23
Show Gist options
  • Save Thaekeh/eab4e8e392d87463b332b840eea7d2d6 to your computer and use it in GitHub Desktop.
Save Thaekeh/eab4e8e392d87463b332b840eea7d2d6 to your computer and use it in GitHub Desktop.
Sort an array by a Boolean value.
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