Last modified on 30 September 2011, at 09:32

Algorithms/Sorting-bubble sort/c method 1

void bubblesort(int a[], int len)
{
    int i, j, tmp;
 
    for(i = 0; i < len; i++)
    {
        for(j = 0; j < len - 1 - i; j++)
	{
           if(a[j] > a[j + 1])
           {
	        tmp = a[j + 1];
		a[j + 1] = a[j];
		a[j] = tmp;
	    }
        }
     }
}