In my code, I have an array that I am looping through in the following way:
<template v-for="plan in plans">
...
</template>
My goal is to sort the plans
array by a calculation based on certain properties of each plan
. Let's say this calculation function is named stockReturns(plan)
.
So, how can I achieve this sorting?
If it was just a matter of ordering by one of the plan's properties, I could do something like this:
v-for="plan in plans | orderBy 'attr'"
But I am having difficulty figuring out the correct syntax for utilizing a function's output within the orderBy
directive.