Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!agate!garnet.berkeley.edu!ked From: ked@garnet.berkeley.edu (Earl H. Kinmonth) Newsgroups: comp.lang.c Subject: Re: Turbo C & qsort() Message-ID: <19922@agate.BERKELEY.EDU> Date: 4 Feb 89 05:24:01 GMT References: <13722@dcatla.UUCP> Sender: usenet@agate.BERKELEY.EDU Distribution: usa Organization: University of California, Berkeley Lines: 32 In article <13722@dcatla.UUCP> pmswl@sunb.UUCP (Scott W. Leonard) writes: > > > >I hope one of you C wizards can help me. I've written a directory >program using Turbo C 2.0. I'm to the point of cleaning it up a >bit. I currently have a file sort function, but it is a bit bulky >and time consuming. I would really like to use Turbo's 'qsort' >function. I've tried it about every way possible, but nothing >seems to work for me. I'm not going to take the time to read through your code. I have enough buggy code of my own to look at. -:) I will give you one major hint. What qsort passes to the sort function has ONE MORE LEVEL OF INDIRECTION than you might expect. For example, if you are trying to sort char *barf[MAXBARF]; the qsort call is qsort( (char *) barf, MAXBARF, sizeof(char **), sortfunc) and sortfunc(as,bs) char **as; char **bs; { return(strcmp(*as,*bs)); } Happy sorting.