Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8222739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:22:47+00:00 2026-06-07T14:22:47+00:00

I have an array of dictionaries. Each dictionary holds data about an individual audio

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:22:49+00:00Added an answer on June 7, 2026 at 2:22 pm

    There is many ways to deal with such a situation.

    One approach could be to consider the number of votes as a measure of the confidence in the rating average. Starts with an average set at 3 (per example).

    const double baseConfidenceRating = 3;
    NSUInteger averageRating = ...;
    NSUInteger voteCount = ...;
    
    const NSUInteger baseConfidence = log10( 1000 );
    double confidence = log10( 1 + voteCount ) / baseConfidence;
    double confidenceWeight = fmin( confidence, 1.0 );
    
    double confidenceRating = (1.0 - confidenceWeight) * baseConfidenceRating + confidenceWeight * averageRating;
    

    Now sort your array based on confidenceRating instead of averageRating.

    You can tweak the algorithm above by changing how many votes are needed so confidenceRating equals averageRating, and of course, you can change the function I used in the example. square root could work as well, or why not a linear progression. Your call.

    This is just an example of course, a pretty dumb one. The standard deviation of the votes may add some intelligence in the algorithm, taking not only the number of votes into account but also the distribution of votes. 100 votes on 100 at 5 have more ‘confidence’ than 1000 votes scattered randomly between 0 and 5. Methink.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a plist file which is an array of dictionaries. Where each dictionary
I have an array of dictionaries. Each dictionary is like this object, @myObject, [NSValue
I have a custom plist file which contains dictionaries. Each dictionary contains information about
I have an array filled with dictionaries. Each dictionary have strings like title, info
I have an array of dictionaries. Within each dictionary, there is a a key
I have an array of dictionaries. Each dictionary has one category. I want to
basically I have an array of dictionaries and each dictionary has a day ,
I have one array that is pre-filled with dictionaries with each dictionary consisting of
I have an array of dictionaries with each a bunch of keys with values.
I have a plist (array of dictionaries) with 20 items, each of the 20

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.