I want to print out a sorted string linked list but my codes sort in the order of entry.
such as :
Code:
Input : e a g c
Outout : e a g c
How can I convert my codes to insert the inputs in actual alphabetic sorted order. Could you help me please?

Code:
void insert_in_order(char *n, node_ptr list)
{
	node_ptr before = list;
	node_ptr new_node = (node_ptr)malloc(sizeof(struct node));
	new_node->name = n;

	while(before->next && (before->next->name < n))
	{
		before = before->next;
	}
	new_node->next = before->next;
	before->next = new_node;
}