質問

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