Hi /sci/, I need some help with choosing a sorting algorithm for a website I'm coding. /g/wdg/ is useless and keeps calling me an autist when I point out that their suggestions are not even related to what I was asking for (for example, one poo in the loo linked me to a tutorial on how to sort an array numerically, which isn't what I was asking for at all).
So here's what I need:
I want to take in how old a given post on my website is and what rating it has, and then output a natural number which ranks the said post. The higher the rank, the higher in the post list it will appear.
This function should create an optimal balance between freshness and quality of content for the users.
What do you suggest, /sci/?
>sorting shit yourself
This is what you do. In your database at a column called 'Rating'.
Then, make an algorithm that by using the date of the post and the likes or whatever it has produces the natural number that ranks the post.
Then, everytime someone likes a post have it run that algorithm to recalculate immediately.
Then, when someone looks up your website simply do this:
SELECT * FROM Posts ORDER BY Rating ASC
>inb4 I'm not using SQL for my database
Then you fucked up. Better start loading up the helium tank.
topkek then I explained him what he already 'knew'.
Real talk here OP. You can ask whatever you want and people will help you with the trivial SQL queries and what not.
BUT DID YOU FUCKING EXPECT SOMEONE TO DO YOUR FUCKING WORK AND CODE YOU THE ALGORITHM?
Are you retarded? Have some sense of shame, OP. It is your fucking website and this would need heavy consideration. How radical do you want it to be? How impactful do you want the date to be? How impactful should every like be? Should be impact of likes diminish as the number of likes grow. Like, the first 'LIKE' really bumps it up but after like 5000 likes then it doesn't have that much impact.
Think for your fucking self, OP.
>reddit had entire team spend months trying to improve their algorithm and still failed
>Dipshit asks to be given an algorithm in a web dev thread and goes autistic when he doesn't have a printed copy of the algorithm and documentation of it written in latex hand delivered to him
>why wont YOU IDIOTS just give me the answer so I can spend three minutes coding it
fuck off OP
Actually, your post reminded me that there is a pretty good solution for this. I highly doubt OP is capable of understanding or using it though.
You can use literally any bubble algorithm then use a reference table to tie the score in an ordered list to the post.
or you can follow roody poos advice and just use array functionality which would be the faster.
Numpy has the arange function which does exactly what you're trying to do,
>What do you suggest, /sci/?
I would suggest
Score = (aggregated user rating) x exp (-t/T)
where t is age and T is the decay rate. T is a tuneable parameter and you can start by using a T that reduces the Score to half the value after one week.
Also (aggregated user score) could be tuned so that late additions receive a lower score to prevent bumping. Again you could use decay rates:
(aggregated user score) = (previous aggrecated user score ) += ((new score) x exp ((time since previous ranking) / R))
Tune R so that a score gets half the value when someone bumps one week after previous ranking.
Use of decay rates are commonly used in mathematical modelling in physics, basic knowledge really.
>Blame CS just because is the sexiest major nowadays.
>Joel Spolsky, one of the creators of stackoverflow, has a BS summa cum laude in Computer Science.
KEEP HATING YOU BROKE NIGGER.
>[Person who works in CS], one of the creators of [Software/CS company] has a [CS degree]
Oh wow. Such deep insight right here! I knew that if I looked deep enough I would find the good CS majors like this one. Just from that post I can calculate an IQ 300.
>A CS graduate has a job in CS-related field
>SEE HOW SUCCESFUL WE ARE! HAHAH!
How much of your life have you wasted baselessly insulting a field of study on 4chan?
Life is short. Don't waste the time you have by being an idiot.
By the way, CS says "you're welcome" for this website.
Having people rate individual posts instead of threads is going to cause people to upvote stuff they agree with (good for a SO clone, bad for a discussion forum).
As for a formula, you should do a little trial and error to see what works best.
Evidently there are two approaches here, either the physics one as in >>7794236 by modelling,
or the CS one which as commented in >>7794269
only addresses half the problem and studiously ignores the OP real problem. Why discuss freshness when you can go all out on a tiny algorithm for ranking ... alone?
If CS wants to demonstrate their superiority they should at the very least come up with a solution rather than alleging it is trivial.
>If CS wants to demonstrate their superiority they should at the very least come up with a solution rather than alleging it is trivial.
But for CS people, it is trivial. CS people have been trained that the solution is simply
>Daily reminder that not once do CS majors have to do any kind of low level programming
>Daily reminder that when given homework, CS students will unironically ask their professors if they are allowed to import a library that basically does it all for them
>Daily reminder that 9 out of 10 times the professor will tell them yes, because he doesn't want 90% of the class to fail because they can't even declare a variable
>Daily reminder that if you do crystal meth, at least you are not destroying your life quite as badly as the computer science student next to you.
Computer science - not even once.