I'm trying to sort an array of objects into a custom order - that is, one where the sort is not logic based but arbitrary.
I currently have it working like this:
sortedAssessments() {
return [
this.assessments.find(assessment => assessment.id === 14),
this.assessments.find(assessment => assessment.id === 15),
this.assessments.find(assessment => assessment.id === 4),
this.assessments.find(assessment => assessment.id === 17)
]
}
But running Array.find 4 times seems quite expensive. Is there a way this could be achieved using Array.sort?