Hello guys! I have an assignment in my data structure class and I want to ask following thing:

I have txt file which is unordered (not sorted) say like this:

red apple
blue sky
white car
handsome boy
hello world

My program should read file into linked list and sort it while reading? for example: it should read first line "red apple" and place it in first order, then it has to read second line "blue sky" and place it in right order that is before "red apple" (alphabetically blue is upper then red). Next lines has to be ordered in this way.

I know how to make linked list. But i don't know how to sort it while reading text file

Note: I can easily apply some sorting algorithm after reading all content of file. But the main point of assignment is that I cannot use any sorting techniques(algorithms) here.

I nearly know sequence how to make. But i'm very weak at coding. So please can anyone help to me to code following sequence?

//get item
//check it with the head of the list
//if it's "before" alphabetically
   //make it the new head and the head its next value
  //iterate through the list performing the same check as above
  //insert when appropriate

Anyone can help me to make it?

Thanks in advance

1> read an item
2> start from the begining of your list:
if(new item > curent node item)
move to next node
3> create a new node with the new data
4> put the new node in the current location.:
*** for this u have to keep the previous node address in some temp variable.

start coding.............