Selection sort to sort linear linked list

Whats problem in sort function (selection sorting is used here)?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  void sort(node *n)
  { int small, temp;
    do { small=n->info;
	m=n;             //m is another node of type "node"
	while(m->next!=NULL)
	 {  if(m->info<small)
	      small=m->info;
	    m=m->next;
	    }
	temp=n->info;
	n->info=small;
	m->info=temp;
	n=n->next;
	} while(n!=NULL);
	}
Topic archived. No new replies allowed.