Frage

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?

War es hilfreich?

Lösung

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).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top