Re: htdig: Sorting results on date


Gilles Detillieux (grdetil@scrc.umanitoba.ca)
Tue, 8 Dec 1998 10:46:41 -0600 (CST)


According to htDig user:
> Is it possible to sort the results of htdig-requests by date?
> I was looking at Display.cc and other parts of the source, but I don't
> know where to start. :-)

Well, I'm just speculating here, because I haven't tried it. I'd start by
adding a new compare() method to the Display class, such as compareDate().
It would be like compare(), except the value it returns would be something
like:
        return m2->getRef()->DocTime() - m1->getRef()->DocTime();

Then, in Display::sort(), you'd have to test the value of a new input
parameter, e.g. input["sortby"], to see if it selects a sort by date.
If so, the final argument it passes to qsort() would be Display::compareDate
instead of Display::comapare.

Note: this would break Display::display(). It assumes the first score of
the first item in the match list is the highest score, which is only true
if the list is sorted by score. You don't want to mess up the scores, as
they're used to show the ranks of the matches (i.e. number of stars). So,
instead of grabbing the first score, you'd have to go through the whole
list and find the highest score.

There'd be a bit more housekeeping stuff as well, associated with the new
input parameter. See how the code deals with other parameters (e.g. restrict,
exclude, and so on) to see how to add the sortby parameter. Finally, you'd
need to change the common/*.html file and the search.html to handle the
new parameter, and pass it on for followup searches.

I think that's the general idea. Good luck with it.

-- 
Gilles R. Detillieux              E-mail: <grdetil@scrc.umanitoba.ca>
Spinal Cord Research Centre       WWW:    http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba  Phone:  (204)789-3766
Winnipeg, MB  R3E 3J7  (Canada)   Fax:    (204)789-3930
----------------------------------------------------------------------
To unsubscribe from the htdig mailing list, send a message to
htdig-request@sdsu.edu containing the single word "unsubscribe" in
the body of the message.



This archive was generated by hypermail 2.0b3 on Sat Jan 02 1999 - 16:29:49 PST