I dug this up off the internet. It seems to work.
#include <stdio.h>
#include <stdlib.h>
char names[5][10]={"tom","anna","tim","alicia","tonya"};
char **keys;
int i=0;
int compare(const void *arg1, const void *arg2);
main(int argc, char *argv[]) {
int strcmp();
keys=malloc(sizeof(char *)*6);
for (i=0;i<5;i++) {
keys=malloc(9);
strcpy(keys,names);
}
qsort(keys,5,sizeof(char *),compare);
for (i=0;i<5;i++) printf("%s\n",keys);
}
int compare(const void *arg1, const void *arg2) {
return strcmp(* (char**) arg1, * (char**) arg2);
}