Insertion sort problem

Hello, Im trying to sort a filled linked list with random numbers. The function I have made doesnt work as it should. I can't see what is wrong, its not sorting the numbers properly. Would really appreciate som help. //Fjantztone

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void linked_list::SortList(){
    if(is_empty())
        {
           return;
        }
   for(node_t *it =head; it!=tail; it = it->next){
      int valToIns = it->value;
      node_t *holePos = it;
      while(holePos->prev && valToIns < it->prev->value){
           holePos->value = holePos->prev->value;
           holePos = holePos->prev;
       }
       holePos->value = valToIns;
   }
}
Topic archived. No new replies allowed.