I'm going to have a mySQL table with elements in it and would like to rank them in the same manner than Reddit but not quite. I'd like to know how to add or remove importance to a variable in my ranking algorithm.

For instance, what I have is a time (a timestamp, so a huge value) and a number of upvotes (a smallish value, under 50). How do I give more importance to the upvotes and less to the time?

1 Answer 1


Multiply each value with a weight, the timestamp will be small while the number of upvotes will be large.

  • Some something like rank = 0.001*timestamp + 10*upvotes?
    – Farid
    Commented Aug 31, 2014 at 23:14
  • @Farid exactly like that. Commented Aug 31, 2014 at 23:15
  • I suspect you really want a factor proportional to (now - timestamp), and not directly timestamp.
    – aecolley
    Commented Sep 1, 2014 at 1:38
  • @aecolley depends if he want older to be more important or less important: now-timestamp vs timestamp-epoch Commented Sep 1, 2014 at 7:43
  • @aecolley @ratchet freak I want older to be less important. Is it timestamp-epoch?
    – Farid
    Commented Sep 1, 2014 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.