ID:261629
 
i have all the players that login in a list (list/Players)how will i sort players by their score/money within a stat panel
Soori-99 wrote:
i have all the players that login in a list (list/Players)how will i sort players by their score/money within a stat panel

The way I did this in Scream of the Stickster was to change their position in the player list whenever their score changed; that isn't necessarily feasible for you, but it's not a bad idea to try. (This won't work for a situation where people want different sort orders.)
mob/proc
rank()
// return some function of score and money, like score+money*10

resort() // adjust position in sort order
while(Players.Remove(null)); // get rid of dead weight
var/i=Players.Find(src)
var/mob/M
if(!i) return
if(i>1)
M=Players[i-1]
while(M.rank()<rank())
Players[i]=M
Players[--i]=src
if(i==1) break
M=Players[i-1]
if(i<Players.len)
M=Players[i+1]
while(M.rank()>rank())
Players[i]=M
Players[++i]=src
if(i==Players.len) break
M=Players[i+1]
Whenever someone is added to the Players list, just call resort() on them to immediately update their position. This will help keep the list in order.

Lummox JR
In response to Lummox JR
thanks :D
In response to Lummox JR
um.. how exactly am i supposed to return the function of score and money
In response to Soori-99
<code>mob/proc rank() return score+money*10 //or whatever </code>
In response to Crispy
*hits himself on the head*