I'm working on a script to create and manage a (music) chart. I'd like to enable anyone to up/down vote a song, and then update the chart on the basis of these votes. But ordering the chart just by the number of votes seems "too easy" to me. How would you do this?

有帮助吗?

解决方案

I want to share the solution I found:

new_position = old_position - floor((number_of_upVotes - number_of_downVotes)/X)

Where X is an arbitrary number. In my case I used 5.

In this way the new position will always be between the highest one (usually 1) and the lowest one (for example 10).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top