Perlfect Solutions
 

[Perlfect-search] Can Search Results Be Sorted by File Name?

Daniel Naber perlfect-search@perlfect.com
Mon, 28 Jul 2003 16:25:16 +0200
On Monday 28 July 2003 15:49, Marc Borbely wrote:

> I'm wondering if there's any way to sort the results of searches by
> filename, instead of by the regular ranking system.

If you make a small change to the search.pl script, yes. Around line 447, you need 
to insert this line:

  @keys = sort {uc($docs_db{$a}) cmp uc($docs_db{$b})} (keys %answer);

and remove these lines:

   if( defined($query->param('sort')) && $query->param('sort') eq 'title' ) {
    @keys = sort {uc($titles_db{$a}) cmp uc($titles_db{$b})} (keys %answer);
  } else {
    @keys = sort {$answer{$b} <=> $answer{$a}} (keys %answer);
  }

Alternatively you could sort by title (your titles then need issue numbers, but 
that might be a good idea anyway). Just set a hidden field:
<input type="hidden" name="sort" value="title">

Regards
 Daniel

-- 
http://www.danielnaber.de