Here is a C program for sorting different types of data in Merge-Sort paradigm . You have to include this program in your application program to use it. And important thing is that you have to specify the type of data you are going to use( Don't worry there is an example). You can sort int,char,char*,float,double,unsigned int,unsigned long types.
Merge-Sort.c contains two useful functions ,those are MergeSort(array,startindex,endindex) and a utility function to print sorted data . Below example uses these .
Here is a C program that uses this program to sort strings ( array of character pointers)
#define type string
#include "MergeSort.c"
int main(void)
{
char* array[]={"C programming","Python Programming","Operating System","Unix","Programs for you","How are you"};
MergeSort(array,0,5);// starting index to last index
PrintArray(array,0,5);
return 0;
}
Here is MergeSort.c .
Let me know if you have any different methods to do this or any questions .
No comments:
Post a Comment