Hi,
I have a list of Places as one data type, and a list of Reviews as another data type. Each Review relates to one of the Places.
A field on each Review is a list of Tags. For example I could have a Place with two Reviews as follows:
Place = Bar in London
Review 1 Tags = [loud, cheap, casual]
Review 2 Tags = [fun, cheap, loud, bright, casual]
What I am trying to do is display the 3 most popular Tags for each Place. So in the example above, I want to display:
Bar in London
Popular Tags: loud, cheap, casual
Currently I am able to get a full list of the Tags, and remove any duplicates using uniqueElements, but this means I am just getting any random Tags rather than the most popular.
I cannot work out how to count the number of each Tag in the full list, and display the most common. Ideally the solution will also allow me to filter by the popular tags in future too.
Here is a screenshot of my app:
Here is my current method:
Note: my data types are actually called ‘Date’, ‘Review’, ‘Vibe’…rather than ‘Place’, ‘Review’, ‘Tag’.