add a field called priority to your links.def file. I set mine to ALPHA with length of 3. Then assign a value to every link in the link.db file using all three places such as 005 or 050 or 500. Higher "numbers" will be listed at the top.
also in links.def set the variable $db_sort_links equal to the field number of the priority field.
and add the $db_priority to the "Field Number of some important fields."
then in db_utils.pl rename the build_sorthit function to build_sorthit_old
insert the following just before the old one:
Code:
sub build_sorthit {
# just priority
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, $hit, $i, @sorted, $column, $type);
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
}
foreach $hit (sort {
$sortby{$b} cmp $sortby{$a};
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}
or i think the following aslo works.
Code:
sub build_sorthit {
# --------------------------------------------------------
# This function sorts a list of links. It has been modified to sort
# new links first, then cool links, then the rest alphabetically. By modifying
# the sort function below, you can sort the links however you like (by date,
# or random, etc.).
#
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, %Priority, %isPriority, $hit, $i, @sorted);
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
$Priority{$i} = $unsorted[$db_priority + ($i * ($#db_cols+1))];
($unsorted[$db_priority + ($i * ($#db_cols+1))] eq "Yes") and ($isPriority{$i} = 1);
} foreach $hit (sort {
($isPriority{$b} and !$isPriority{$a}) and return 1;
($isPriority{$a} and !$isPriority{$b}) and return -1;
($isPriority{$a} and $isPriority{$b}) and return $Priority{$a} cmp $Priority{$b};
$sortby{$b} <=> $sortby{$a};
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}
Gene "The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."