pocorschi
pocorschi

Reputation: 3665

Sorting a list based on multiple indices and weights

Sort of a very long winded explanation of what I'm looking at so I apologize in advance.

Let's consider a Recipe:

Take the bacon and weave it ...blahblahblah...

This recipe has 3 Tags

I am a new user that sees a list of randomly sorted recipes (my palate/profile isn't formed yet). I start interacting with different recipes (reading them, saving them, sharing them) and each interaction adds to my profile (each time I read a recipe a point gets added to the respective category/author/subcategory). After a while my profile starts to look something like this :

Now, the point of all this exercise is to actually sort the recipe list based on the individual user's preferences. For example in this case I will always see Chandler Bing's recipes on the top (regardless of category), then Ramsey's recipes. At the same time, Bing's recipes will be sorted based on my preferred categories and subcategories, seeing his fast food recipes higher than his haute cuisine ones.

What am I looking at here in terms of a sorting algorithm? I hope that my question has enough information but if there's anything unclear please let me know and I'll try to add to it.

Upvotes: 1

Views: 236

Answers (4)

lxg
lxg

Reputation: 13107

I think what you're looking for is not a sorting algorithm, but a rating scheme.

You say, you want to sort by preferences. Let's assume, these preferences have different “dimensions”, like level of complexity, type of cuisine, etc.

These dimensions have different levels of measurement. These can be e.g. numeric or simple categories/tags. It would be your job to:

  1. Create a scheme of dimensions and scales that can represent a user's preferences.
  2. Operationalize real-world data to fit into this scheme.
  3. Create a profile for the users which reflects their preferences. Same for the chefs; treat them just like normal users here.

To actually match a user to a chef (or, even to another user), create a sorting callback that matches all your dimensions against each other and makes sure that in each of the dimension the compared users have a similar value (on a numeric scale), or an overlapping set of properties (on a nominal scale, like tags). Then you sort the result by the best match.

Upvotes: 0

kipodi
kipodi

Reputation: 409

You can use a recursively subdividing MSD (sort of radix sort algorithm). Works as follows:

Take the most significant category of each recipe.

Sort the list of elements based on that category, grouping elements with the same category into one bucket (Ramsay bucket, Bing bucket etc).

Recursively sort each bucket, starting with the next category of importance (Meat bucket etc). Concatenate the buckets together in order.

Complexity: O(kn) where k is the number of category types and N is the number of recipes.

Upvotes: 0

Frumples
Frumples

Reputation: 433

I would allow the "Tags" with the most importance to have the greatest capacity in point difference. Example: Give author a starting value of 50 points, with a range of 0-100 points. Give Category a starting value of 25 points, with a possible range of 0-50 points, give subcategory a starting value of 12.5 points, with a possible range of 0-25 points. That way, if the user's palate changes over time, s/he will only have to work down from the maximum, or work up from the minimum.

From there, you can simply add up the points for each "Tag", and use one of many languages' sort() methods to compare each recipe.

Upvotes: 1

r0dney
r0dney

Reputation: 745

You can write a comparison function that is used in your sort(). The point is when you're comparing two recipes just add up the points respectively based on their tags and do a simple comparison. That and whatever sorting algorithm you choose should do just fine.

Upvotes: 0

Related Questions