Let's say I have three objects
[
{
'name' : 'Apple',
'popularityFoo': 100,
'popularityBar': 80,
'popularity': 40,
},
{
'name' : 'Banana',
'popularityFoo': 50,
'popularityBar': 90,
'popularity': 50,
},
{
'name' : 'Cherry',
'popularityFoo': 60,
'popularityBar': 60,
'popularity': 60,
}
];
My default sorting is by popularity, returning Cherry (60), Banana (50), Apple (40)
If a user has a preferred category it will sort first by that category popularity index and then fall back to popularity. So if my favorite category is Foo it returns Apple (100), Cherry (60), Banana (50) and for category Bar the search returns Banana (90), Apple (80), Cherry (60)
Now my question: If my user likes both Foo and Bar how can I compare the different popularity values with each other when sorting so I can get the result Apple (100), Banana (90), Cherry (60)? Am I indexing wrong? Should I approach this differently?
I have 20 categories and my users have 1-3 favorite categories.