I've installed the randomizing code to my db_utils.pl from this post
http://www.gossamer-threads.com/...20order%20of%20links;
everything is great except it's pretty much useless to me unless the pop&new links always stay on top and don't mix up with rest of the links every time I do a "build". I've spend around 3-4 hours working with the code and couldn't do anything.
I've read this thread http://www.gossamer-threads.com/...20order%20of%20links; and had tried every suggestion listed there atleast twice with no luck
so I've decided to make a thread here hoping that somone was successful in making it work
Here's what I have so far, the original code has been replaced in sub build_sorthit { in db_utils.pl
with this
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, %isnew, %iscool, $hit, $i, @sorted);
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
if ($unsorted[$db_isnew + ($i * ($#db_cols+1))] eq "Yes") { $isnew{$i} = 1; }
if ($unsorted[$db_ispop + ($i * ($#db_cols+1))] eq "Yes") { $iscool{$i} = 1; }
}
srand;
foreach $hit (sort { return int(rand(1) + 0.5) ? 1 : -1 } (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}
I also changed variable $db_sort_links in links.def file to equal 8 - $db_sort_links = 8; (don't know what it does) but people say it's needed.
Right now it randomizes all my links along with the new and pop, how do I get around that? :(
If you know how to handle this please reply I'd be VERY thankful and will help you our in anyting I can
Thanx in advance, cheers
http://www.gossamer-threads.com/...20order%20of%20links;
everything is great except it's pretty much useless to me unless the pop&new links always stay on top and don't mix up with rest of the links every time I do a "build". I've spend around 3-4 hours working with the code and couldn't do anything.
I've read this thread http://www.gossamer-threads.com/...20order%20of%20links; and had tried every suggestion listed there atleast twice with no luck
so I've decided to make a thread here hoping that somone was successful in making it work
Here's what I have so far, the original code has been replaced in sub build_sorthit { in db_utils.pl
with this
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, %isnew, %iscool, $hit, $i, @sorted);
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
if ($unsorted[$db_isnew + ($i * ($#db_cols+1))] eq "Yes") { $isnew{$i} = 1; }
if ($unsorted[$db_ispop + ($i * ($#db_cols+1))] eq "Yes") { $iscool{$i} = 1; }
}
srand;
foreach $hit (sort { return int(rand(1) + 0.5) ? 1 : -1 } (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}
I also changed variable $db_sort_links in links.def file to equal 8 - $db_sort_links = 8; (don't know what it does) but people say it's needed.
Right now it randomizes all my links along with the new and pop, how do I get around that? :(
If you know how to handle this please reply I'd be VERY thankful and will help you our in anyting I can
Thanx in advance, cheers