I want to create a sorting algorithm that takes an items score (based on upvotes/downvotes) and sorts them based on an invisble underlying score that take time decay into account.
Being from the analytic philosophy side, my mathematical algorithms aren’t always the best. What is a simple elegant way to solve for InverseTimeRelationship(currentItem.CreationDate) in the following example:
class Item()
{
int upvotes;
int downvotes;
int SortScore;
DateTime CreationDate;
}
var currentItem = GetSomeSpecificItemMethod();
int Score = currentItem.upvotes - currentItem.downvotes;
currentItem.SortScore = Score * InverseTimeRelationship(currentItem.CreationDate);
SortItemsBySortScore(Item[]);
InverseTimeRelationship(DateTime CreationDate)
{
//Code To Write
}
The hope being that after a day, the SortScore would be a little lower, but after say 2-3 days no matter how many votes it has, it will disappear from the top of the list/front page.
You can take a look at the algorithm reddit uses. It seems to be what you want.