home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
APPS
/
dm.lzh
/
shellsort.c
< prev
next >
Wrap
Text File
|
1995-04-03
|
741b
|
33 lines
/* Shell sort of string v[0] .... v[n-1] into increasing
* order.
* Reference CPL pg. 108.
*/
shellsort(filecount)
int filecount;
{
int gap, i, j;
char *temp;
char *tempfd;
short attr;
extern char **nameptr;
extern char **fildesptr;
extern short *attrptr;
for (gap = filecount/2; gap > 0; gap = gap / 2)
for (i = gap; i < filecount; i++)
for (j = i - gap; j >= 1; j = j - gap){
if (strcmp(nameptr[j], nameptr[j+gap]) <= 0)
break;
temp = nameptr[j];
nameptr[j] = nameptr[j + gap];
nameptr[j + gap] = temp;
tempfd = fildesptr[j];
fildesptr[j] = fildesptr[j + gap];
fildesptr[j + gap] = tempfd;
attr = attrptr[j];
attrptr[j] = attrptr[j + gap];
attrptr[j + gap] = attr;
}
}