Is This Valid Insertion Sort?

I coded this up to use insertion sort on linked lists. It just doesn't seem like a valid insertion sort. My predictions on swaps and comparisons are off, so I'm just wondering if someone could give this a gander. By the way, the output of the linked list is correct. I'm just concerned with the validness of the algorithm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
nodeType<Type> *beforeFirstOutOfOrder;
    nodeType<Type> *firstOutOfOrder;
    nodeType<Type> *minNode;
    
    for (beforeFirstOutOfOrder = unorderedLinkedList::first; beforeFirstOutOfOrder != NULL; beforeFirstOutOfOrder = beforeFirstOutOfOrder->link)
    {
        minNode = beforeFirstOutOfOrder;
        
        for (firstOutOfOrder = beforeFirstOutOfOrder->link; firstOutOfOrder != NULL; firstOutOfOrder = firstOutOfOrder->link)
        {
            if ((firstOutOfOrder->info) < (minNode->info))
            {
                minNode = firstOutOfOrder;
            }
            comparisons++;
        }
        swap(beforeFirstOutOfOrder, minNode);
        
    }
Topic archived. No new replies allowed.