Merge Sort..
-------------------------------------------------------------------
#include<stdio.h>
#include<malloc.h>
#include<string.h>
void mergesort(char a[], int l, int r){
int i, j, k, m;
char *b;
b = (char *)malloc(r+1);
if(r>l){
m = (r+l)/2;
mergesort(a, l, m);
mergesort(a, m+1, r);
for(i=m+1; i>l; i--) b[i-1] = a[i-1];
for(j=m; j<r; j++) b[r+m-j] = a[j+1];
for(k=l; k<=r; k++) a[k] = (b[i]<b[j]) ? b[i++] : b[j--];
}
}
void main(){
char chr[]="asortingexmple";
mergesort(chr, 0, strlen(chr)-1);
printf("sort : %sn", chr);
}
-------------------------------------------------------------------