Skip to content

Instantly share code, notes, and snippets.

@Sreyas-Sreelal
Last active November 13, 2016 16:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sreyas-Sreelal/42f6f9e1c50f9696530eeaac2c82222f to your computer and use it in GitHub Desktop.
Save Sreyas-Sreelal/42f6f9e1c50f9696530eeaac2c82222f to your computer and use it in GitHub Desktop.
Sorts the strings in alphabetic order
#define strcpy(%0,%1) strcat((%0[0] = '\0', %0), %1)
/*Alphabet sorter by Sreyas*/
alpha(str[MAX_NAMES][MAX_PLAYER_NAME]) //MAX_NAME - total number of strings in that matrix
{
new i, j,t[24];
for(i=1; i<MAX_NAMES; i++)
{
for(j=1; j<MAX_NAMES; j++)
{
if(strcmp(str[j-1], str[j])>0)
{
strcpy(t, str[j-1]);
strcpy(str[j-1], str[j]);
strcpy(str[j], t);
}
}
}
printf("Names in alphabetical order ");
for(i=0; i<MAX_NAMES; i++)
{
printf("%s",str[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment