I have a Posts table with a lot of posts submitted at various times, and every post has a rating with it. For question’s sake let’s say I have all the required details in the Posts table itself (i.e.contents, ratings, created_at etc are in the Posts table).
I need an algorithm to sort the Posts intelligently based on their ratings and how recently they’ve been posted.
I’m using MySQL backend, so a query would be appropriate.
Asking Google really isn’t that hard. the first hit seems to be really good, the second one even is a topic on SO about this, leading to a great article about Bayesian rating which seems to be what you’re looking for.
The rest is simple maths – by the Bayesian rating you can easily decide which posts are the best. to take the time into account, simply divide the rating by the minutes since the post was created (for example) and the result is a good rating that take the creation-time into account.