#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *sources[] = {"this", "is", "a", "program", "for", "testing"};
void printarray (char **stringarray, int length)
{
int i = 0;
for (i; i < length; i++)
{
printf("%s ",stringarray[i]);
}
printf("\n");
}
int compare (const void *element1, const void *element2)
{
return strcmp(*(const char**)element1,*(const char **)element2);
}
int main (int argc, const char * argv[])
{
printarray(sources,6);
qsort(sources, 6, sizeof(char *), compare);
printarray(sources,6);
return 0;
}