How would I implement a ranking algorithm in my website to sort database data?
问题 I want to implement a ranking system on a website I've been working on and have decided to go with the Hacker News algorithm. My reasoning for choosing this algorithm is simply because it's been described here. I was looking at this Python code (the language I'm using to build my site) and couldn't figure out how I would implement it. def calculate_score(votes, item_hour_age, gravity=1.8): return (votes - 1) / pow((item_hour_age+2), gravity) Given the tables: posts: id | title | time