mercredi 16 novembre 2016

Picking random entries from dictionary based on value

I have a dictionary with restaurants and a type of restaurant like this: Dictionary<Restaurant, string> Where restaurants is my class and for simplicity I use a string for my type of restaurant.

Let's say I have 25 entries in my list, where there can be groups of 3, 4 or 5 restaurants with the same type. Now I want to narrow this down to select 1 random element per type.

I have found this page which explains how to pick random values from a dictionary, but how would I go around picking a random entry per grouping of type?

Let me know if I should elaborate more or if you need additional information!




Aucun commentaire:

Enregistrer un commentaire