/*TITLE test sorting program*/

/****keyword-flag*** "%v %f %n" */
/* "4 20-Mar-98,22:22:50 SORTTEST.CPP" */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void Megasort(unsigned char **PtrArray, unsigned *RecNums, int KeyLength, 
unsigned ArraySize);

int sort_function(const void *a, const void *b);


main(int argc,char *argv[])
{
	int i;
	int j;
	char **string;
	int *recnum;
	int sort_count;
	int string_length;
	char *string1;
	char *string2;
	int loop_count;

	if (argc < 3)
		{
		printf("Usage: sorttest sort-count string-length\n");
		exit(0);
		}
	sort_count = atoi(argv[1]);
	string_length = atoi(argv[2]);
	string = (char **)calloc(sort_count,sizeof(char *));
	recnum = (int *)calloc(sort_count,sizeof(int));
	for (i = 0; i < sort_count; i ++)
		{
		string[i] = calloc(string_length+1,1);
		for (j = 0; j < string_length; j ++)
			string[i][j] = (rand() % 26) + 97;
		recnum[i] = i;
		}

	if (sort_count <= 4000)
		qsort(string[0],sort_count,16,sort_function);

	Megasort(string,recnum,string_length,sort_count);
}

int sort_function(const void *a, const void *b)
{
	return(strcmp(a,b));
}

