123456789101112131415161718192021
void qsort(Dict DictEntries[MAXENTRIES],int start,int finish) { int left=start, right=finish; char *pivot=DictEntries[(start+finish)/2].key; while (left < right) { // find left candidate while ((strcmp(DictEntries[left].key,pivot)<0) && (left<right)) left++; // find right candidate while ((strcmp(DictEntries[right].key,pivot)>0) && (right>left)) right--; if (left <= right) { Dict temp = DictEntries[left]; DictEntries[left] = DictEntries[right]; DictEntries[right] = temp; left++; right--; } } // while left < right if (start < right) qsort(DictEntries,start,right); if (left < finish) qsort(DictEntries,left,finish); }