I am looking to organize an array of objects by filtering out items based on a value returned from a function, and then only return the objects' items that exceed a certain threshold.
Here is my attempt at achieving this:
sortedObject(){
return this.arrayOfObjects.sort((a, b) =>
(this.formatValue(b) > 0.7) - (this.formatValue(a) > 0.7)
)
}
The function this.formatValue
takes an item and calculates a value between 0 and 1 based on its properties. I want to sort and filter the items such that only those with a value above 0.7 are included in the sortedObject
computed property. Any item with a value below 0.7 will not be part of the sorted result.