Store it in some form of structure, with an appropriate sort function, and let it sort according to the votes given.
Somethign like this in C would do:
Code:
#include <stdio.h>
typedef struct{
char* name;
int votes;
}player;
int size(player* pl);
int sort(player* pl, int size);
int show(player* pl, int size);
int main()
{
int i;
player pl[] = {
{"Jimmy Page", 97},
{"Jeff Beck", 15},
{"Jimmy Hendrix", 105},
{"David Gilmore", 90},
{NULL, 0}
};
i=size(pl);
printf("Befor sort\n");
show(pl, i);
if(0 < i)
sort(pl,i);
printf("After sort:\n");
show(pl, i);
return 0;
}
int size(player* pl)
{
int i;
if(!pl)
return -1;
for(i=0; NULL != pl[i].name; ++i)
;/* just count*/
return i;
}
int show(player* pl, int size)
{
int i;
for(i=0; i < size; ++i)
printf("Player:\t%s\nVotes:\t%d\n", pl[i].name, pl[i].votes);
return 0;
}
int sort(player* pl, int size)
{
int i,j;
player tmp;
for(i=0; i<size-1; i++)
{
for(j=0; j < size-1-i; j++)
{
if ( (*(pl+j)).votes > (*(pl+j+1)).votes )
{
tmp = *(pl+j);
*(pl+j) = *(pl+j+1);
*(pl+j+1) = tmp;
}
}
}
return 0;
}