Question: Update: OK I see it's a bubble sort, but is it less efficient because it doesn't stop when there's no swap on a particular run? It runs until first is null.

Hi, I have a sorting algorithm as follows. My question is, which sorting algorithm is this? I thought it was bubble sort, but it does not do multiple runs. Any idea?
Thanks!

```
//sorting in descending order
struct node
{
    int value;
    node* NEXT;
}
//Assume HEAD pointer denotes the first element in the //linked list
// only change the values…don’t have to change the //pointers

Sort( Node *Head)
{
    node* first,second,temp;
    first= Head;
    while(first!=null)
    {
        second=first->NEXT;
        while(second!=null)
        {
            if(first->value < second->value)
            {
                temp = new node();
                temp->value=first->value;
                first->value=second->value;
                second->value=temp->value;
                delete temp;
            }
            second=second->NEXT;
        }

        first=first->NEXT;
    }
}

```

Answer: 
[Insertion sort](http://en.wikipedia.org/wiki/Insertion_sort)

It's very similar to a bubble sort, except that instead of wapping adjacent pairs of items, you move the smallest item to the head of the list, and then the next smallest item into the second position, and so on.
Its similar to [selection sort](http://en.wikipedia.org/wiki/Selection_sort). In selection sort we find the min value in the list and swap with the first element and repeat the same for other elements in the list. But there we are not swapping after finding the min element, instead everytime we find an element smaller than the first element ( in the first pass) we swap it with the 1st element.