This is how GunGame does it.
Code:
public get_sorted_players()
{
new i, count;
static sort[33][2], maxPlayers;
if(!maxPlayers) maxPlayers = get_maxplayers();
for(i=1;i<=maxPlayers;i++)
{
sort[count][0] = i;
sort[count][1] = score[i];
count++;
}
SortCustom2D(sort,count,"stats_custom_compare");
}
// our custom sorting function (check second dimension for score)
public stats_custom_compare(elem1[],elem2[])
{
if(elem1[1] > elem2[1]) return -1;
else if(elem1[1] < elem2[1]) return 1;
return 0;
}
Assuming that "score" is the variable that you want to sort by. When it's done, sort[0][0] = highest scoring player's id, sort[0][1] = highest scoring player's score; sort[1][0] = second highest scoring player's id, sort[1][1] = second highest scoring player's score; etcetera.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS