Here's some C code of some sorting algo's:

*Bubble Sort*

void BubbleSort(int a[])

{

int i,j;

for (i=MAXLENGTH; --i >=0;) {

swapped = 0;

for (j=0; j<i;j++) {

if (a[j]>a[j+1]) {

Swap[a[j],a[j+1]);

swapped=1;

}

}

if (!swapped) return;

}

}

*Heap Sort*void Heapify(int A[],int i,int HeapSize)

{

int left=2*i, right=2*i+1;

int largest;

if ((left <= HeapSize) &&

(A[left] > A[i]))

largest = left;

else

largest = i;

if ((right <= HeapSize) &&

(A[right] > A[largest]))

largest = right;

if (largest != i) {

Swap(&A[i],&A[largest]);

Heapify(A,largest,HeapSize);

}

}

void HeapSort(int A[], int n)

{

int i, HeapSize = n;

for (i= HeapSize/2; i >= 1; i--)

Heapify(A,i,HeapSize);

for (i=n; i>=2; i--) {

Swap(&A[i],&A[1]);

HeapSize--;

Heapify(A,1,HeapSize);

}

}

*Insertion Sort*void InsertionSort(LIST A)

{

int f, i;

KEYTYPE temp;

for (f = 1; f < MAXDIM; f++) {

if (A[f] > A[f-1]) continue;

temp = A[f];

i = f-1;

while ((i>=0)&&(A[i]>temp)) {

A[i+1] = A[i];

i--;

}

A[i+1]=temp;

}

}

*Quick Sort*int FindPivot(int A[],int l, int r)

{

switch (choice) {

case 1: return l;

case 2: return pivot2(A,l,h)

case 3: return l+random(r-l);

}

}

int partition(int A[], int l, int r)

{

int i,pivot, pivotpos;

pivotpos = FindPivot(A,l,r);

swap(&A[l],&A[pivotpos]);

pivotpos = l;

pivot = A[pivotpos];

for (i = l+1; i <= r; i++) {

if (A[i] < pivot) {

pivotpos++;

swap(&A[pivotpos],&A[i]);

}

}

swap(&A[l],&A[pivotpos]);

return pivotpos;

}

void QuickSort(int A[], int l,int r,

int threshold)

{

int i, pivot;

if (r-l>threshold) {

delay(CompareDelay);

pivot = partition(A,l,r);

QuickSort(A,l,pivot-1,threshold);

QuickSort(A,pivot+1,r,threshold);

}

}

int pivot2(int A[], int l, int r)

{

int i = (r+l)/2;

if ((A[l] <= A[i]) && (A[i] <= A[r]))

return i;

if ((A[r] <= A[i]) && (A[i] <= A[l]))

return i;

if ((A[r] <= A[l]) && (A[l] <= A[i]))

return l;

if ((A[i] <= A[l]) && (A[l] <= A[r]))

return l;

if ((A[l] <= A[r]) && (A[r] <= A[i]))

return r;

if ((A[i] <= A[r]) && (A[r] <= A[l]))

return r;

}

**Selection Sort**void SelectSort(int A)

{

int i, j, min, t;

for (i =1; i<= MAXSIZE; i++) {

min = i;

for (j = i+1; j<=MAXSIZE; j++)

if (A[j] < A[min])

min = j;

Swap(&A[min],&A[i]);

}

}

*Shell Sort*void ShellSort(int A[])

{

int i, j, h=1, v;

do

h = 3*h+1;

while (h <= MAXSIZE);

do {

h /= 3;

for (i=h+1; i<= MAXSIZE; i++) {

v = A[i];

j = i;

while ((j>h) && (A[j-h] > v)) {

A[j] = A[j-h];

j -= h;

}

A[j] = v;

}

} while (h > 1);

}