Gossamer Forum
Home : Products : Links 2.0 : Customization :

Sorting Links - Why are mine not sorted.

Quote Reply
Sorting Links - Why are mine not sorted.
Please reply in group to JamesP@writeme.com

In my small links site (400 links) none of the links seem to be sorted.

There are not sorted by...
A -Z
Link ID
Hits
Rating
or Date Added

Please help.

The URL Is

www.gwgateway.com
Quote Reply
Re: Sorting Links - Why are mine not sorted. In reply to
Actually your links are sorting fine or at least by the default configurations, which sorts links in the following manner:

1) New
2) Ratings
3) A-Z

What you need to do is edit the sub build_sorthit in the db_utils.pl file. There are a few Threads in this forum that provide instructions on how to do this.

But if you can't find the Threads, here is what you need to do:

Replace the sub build_sorthit routine with the following codes:

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, $hit, $i, @sorted);
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
}
foreach $hit (sort {
return lc($sortby{$a}) cmp lc($sortby{$b});
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;

}

This will put your links in alphabetical order.

Regards,


------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Sorting Links - Why are mine not sorted. In reply to
I would just like to sort by number of hits
first regardless if they are new and then, new, then alphabetical. Can someone help
me with a modification to do this?

Mike
http;//www.sweepstalk.com
Quote Reply
Re: Sorting Links - Why are mine not sorted. In reply to
I just wrote some codes last week that sorts first by hits, then new, and then alphabetically...Try searching the forum again.

Use search words like "sort" "buildhits" "db_util.pl file".

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. Smile
----------------------











[This message has been edited by Eliot (edited February 14, 2000).]