문제

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