I have an array of dictionaries. Each dictionary holds data about an individual audio track. My app uses a star rating system so users can rate track 1-5 stars. Each dictionary has its own rating data per track, as follows:
avgRating
(ex: 4.6)rating_5_count
(integer representing how many 5-star ratings a track received)rating_4_count
rating_3_count
rating_2_count
rating_1_count
I'm trying to create a Top Charts table in my app. I'm creating a new array with objects sorted by avgRating
. I understand how to sort the objects using NSSortDescriptors
, but here is where I'm running into trouble...
If I only use avgRating
as a sort descriptor, then if a track only receives one 5-star rating, it will jump to the top of the charts and beat out a track that might have a 4.9 with hundreds of votes.
I could set a minimum vote count to prevent this in the Top Charts array, but I would rather not do this. I would then have to change the min vote count as I get more users.
This is a bit subjective, but does anyone have any other suggestions on how to effectively sort the array?