After searching and experimenting for hours I found a solution
I changed in links.def
$db_sort_links = 1;
to
$db_sort_links = 11; (11=rating field)
and here are the changes
(red) in sub_build_sorthit in db_utils.pl
Code:
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, %isnew, $hit, $i, @sorted);
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
($unsorted[$db_isnew + ($i * ($#db_cols+1))] eq "Ja") and ($isnew{$i} = 1);
($unsorted[$db_ispop + ($i * ($#db_cols+1))] eq "Ja") and ($iscool{$i} = 1);
}
foreach $hit (sort {
($isnew{$b} and !$isnew{$a}) and return 1;
($isnew{$a} and !$isnew{$b}) and return -1;
($iscool{$b} and !$iscool{$a}) and return 1;
($iscool{$a} and !$iscool{$b}) and return -1;
($isnew{$a} and $isnew{$b}) and return lc($sortby{
$b})
<=> lc($sortby{
$a});
($iscool{$a} and $iscool{$b}) and return lc($sortby{
$b})
<=> lc($sortby{
$a});
return lc($sortby{
$b})
<=> lc($sortby{
$a});
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}
Now the links are sorted
1. new links
2. rated links (10 first - 1 last)
Example:
http://www.gpaed.de/...blaetter/Mathematik/ BUT and that's my question
unrated links are in random order ??? Is there a way to sort unrated links by ID oder date or hits????
Thanks in advance
Matthias
Matthias
gpaed.de