daunD
Convex Community3y ago
3 replies
daun

Order by weighted sum (or weighted average) of two indexes

Hi 🙂 I was implementing a feed item sorting algorithm and wondering if it is possible to order rows by weighted sum or somehow dynamically scored standard of two indexes.
For example, weighting recency (_createdAt) and popularity (numLikes, etc) together is very common for sorting a trending item.
One idea I've thought myself is to pre-calculate weights for ordering table with cron job or every popularity event invocation but it felt sub-optimal.
Was this page helpful?