Gossamer Forum
Home : Products : Links 2.0 : Customization :

Re: [doolittle] Sorting Links (Yes I know...Not again!!) :-D

Quote Reply
Re: [doolittle] Sorting Links (Yes I know...Not again!!) :-D In reply to
Right, I've got this working. However, in one category I still get something weird. It first gives a cool link, then a normal link, than my 'priority' link (Laila) and than the new links followed by the normal links.

You can see it here: http://www.gran-canaria-info.com/...ts/Playa_del_Ingles/

In my other categories I haven't found something like this.

I don't see where the problem orginates. Can somebody help?

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, %isnew, %iscool, $hit, $i, @sorted); for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
($unsorted[$db_priority + ($i * ($#db_cols+1))] eq "Yes") and ($priority{$i} = 1);
($unsorted[$db_isnew + ($i * ($#db_cols+1))] eq "Yes") and ($isnew{$i} = 1);
($unsorted[$db_ispop + ($i * ($#db_cols+1))] eq "Yes") and ($iscool{$i} = 1);
}
foreach $hit (sort {
($priority{$b} and !$priority{$a}) and return 1;
($priority{$a} and !$priority{$b}) and return -1;
($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;
($priority{$a} and $priority{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
($isnew{$a} and $isnew{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
($iscool{$a} and $iscool{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
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;
}
Subject Author Views Date
Thread Sorting Links (Yes I know...Not again!!) :-D VickieB 7899 Apr 11, 1999, 4:32 PM
Post Re: Sorting Links (Yes I know...Not again!!) :-D
phoenix 7742 Apr 11, 1999, 4:48 PM
Post Re: Sorting Links (Yes I know...Not again!!) :-D
Alex 7759 Apr 11, 1999, 9:28 PM
Post Re: Sorting Links (Yes I know...Not again!!) :-D
VickieB 7768 Apr 11, 1999, 9:57 PM
Post Re: Sorting Links (Yes I know...Not again!!) :-D
Bobsie 7790 Apr 11, 1999, 10:57 PM
Post Re: Sorting Links (Yes I know...Not again!!) :-D
VickieB 7780 Apr 12, 1999, 1:37 AM
Thread Re: Sorting Links (Yes I know...Not again!!) :-D
Alex 7762 Apr 12, 1999, 1:55 PM
Thread Re: [Alex] Sorting Links (Yes I know...Not again!!) :-D
Coffee 5744 Jan 8, 2005, 9:04 AM
Post Re: [Coffee] Sorting Links (Yes I know...Not again!!) :-D
bugsie 5361 Jun 27, 2006, 4:53 PM
Post Re: Sorting Links (Yes I know...Not again!!) :-D
VickieB 7754 Apr 12, 1999, 2:46 PM
Post Re: Sorting Links (Yes I know...Not again!!) :-D
kiel1 7750 Nov 24, 1999, 4:31 PM
Post Re: Sorting Links (Yes I know...Not again!!) :-D
Tiny Giants 7741 Nov 28, 1999, 2:40 PM
Post Re: Sorting Links (Yes I know...Not again!!) :-D
Tj2000 7741 Nov 29, 1999, 6:19 AM
Post Re: Sorting Links (Yes I know...Not again!!) :-D
doolittle 7770 Apr 19, 2000, 7:58 PM
Thread Re: Sorting Links (Yes I know...Not again!!) :-D
doolittle 7747 Apr 20, 2000, 4:41 AM
Thread Re: [doolittle] Sorting Links (Yes I know...Not again!!) :-D
Lex 6286 May 26, 2003, 5:53 AM
Thread Re: [Lex] Sorting Links (Yes I know...Not again!!) :-D
Lex 6238 Jun 10, 2003, 2:04 PM
Post Re: [Lex] Sorting Links (Yes I know...Not again!!) :-D
poscon 5833 Aug 24, 2004, 10:51 AM