Sorting Linked Lists

I'm currently trying to sort Nodes in a linked-list in order, as they're typed in.

1
2
3
4
5
6
7
struct Node
{
	int studentid;
	string studentinitials;
	double testscore;
	Node *next;
};

^The data structure Node.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Node * start = NULL;
   int sid;
   int target;
   string init;
   double test;
   do
   {
	   Node * curr = new Node;
	   cout << "Enter the Student ID Number:";
		cin >> sid;

		if(sid==-999) break;
		curr->studentid = sid;
		cout << "Enter the Initials:";
		cin >> init;
		curr->studentinitials=init;
		cout << "Enter the test score:";
		cin >> test;
		curr->testscore=test;
		curr->next  = start;
		start = curr;
		cout << "Node with ID = " << curr->studentid << ", Initials = " << curr->studentinitials << ", and test-score=" << curr->testscore <<" added to the end of the list.\n";
   }while(true);


This is how the nodes are currently inserted. I'm just looking for some general guidance on how to sort nodes into order by their Student ID as they get entered in. Thanks!
Topic archived. No new replies allowed.