~Rick wrote: > Hi all, > > I currently call qsort to sort an array of structures. It works fine, > but I would like to sort multiple fields. Can this be done? Is there > another, or better, sort available to do this? Do I somehow do this > in my compareEntry routine? > > Here is the call I am using currently: qsort(linedata, (bufcnt - 1), > sizeof(ENTRY), compareEntry); > > linedata is an array of (ENTRY) structures, bufcnt-1 is the number of > structures to sort. > > > ~Rick
If field 1 is identical, then fall through to field 2. If field 2 is identical, then fall through to field 3. And so on, for all the fields you want to sort on. The value you return from the comparison function tells whether the first ENTRY structure is less than, equal, or greater than the second ENTRY structure. -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* MyTaskFocus 1.1 Get on task. Stay on task. http://www.CubicleSoft.com/MyTaskFocus/
