before inserting the element into the list *people you should check the the correct position. try this:
struct person *insert_sorted (struct person *people, char *name, int age) {
//create a new space for the new person
struct person *pointer = malloc(sizeof(struct person));
// check it succeeded
if(pointer == NULL)
{
printf("The program could not allocate memory ");
exit(-1);
}
// set the data for the new person
strcpy(pointer -> name, name);
pointer -> age = age;
struct person *cursor = people;
struct person *previous = people;
if(people == NULL){
pointer->next = NULL;
return pointer;
}
while(cursor!=NULL && strcmp(pointer->name,cursor->name)<0){
previous = cursor;
cursor = cursor->next;
}
if(previous!=NULL)
previous->next = pointer;
pointer->next = cursor;
return people;
}
in this way you insert the new element after the first element with a name alphabetically lower and you link it with the next element.