Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Sorting a database

Quote Reply
Sorting a database
Hi

I am thinking of using Links for a classified Ads section to a website, I have a testsite up and running, but the problem is that the list of entries that Links prints to screen is last entry goes to the bottom of the list Unsure

How can I make a change so that the latest entry show at the top of the list, for example today's date goes on top, yesterday underneath, acsending as opposed to desendingSmile

TIA
Quote Reply
Re: [johnnyic] Sorting a database In reply to
It normally works in this order;

Is New,
Popularity,
Then alphabetically.

I'm sure there is something you can modify in Links 2 to make it sort by date, but I don't have a copy available (in at collage).

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Sorting a database In reply to
>>but I don't have a copy available<<

Hehe nice excuse.

http://www.gossamer-threads.com/...ts/source/links2.zip
Quote Reply
Re: [RedRum] Sorting a database In reply to
Quote:
Hehe nice excuse.
Yeah, I think you will find it is. I'm at collage (i.e. dont have WinZip), and file downloads are disabled Wink

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Sorting a database In reply to
I've never heard of a university that disables downloading files.

I can understand mp3's and mpeg's but not zips.

Last edited by:

RedRum: Feb 20, 2002, 6:27 AM
Quote Reply
Re: [johnnyic] Sorting a database In reply to
>>
How can I make a change so that the latest entry show at the top of the list, for example today's date goes on top, yesterday underneath, acsending as opposed to desending
<<

It should already do it by default. New links go to the top.

You'll need to look at sub build_sorthit in db_utils.pl

Code:
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{$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});
}
Quote Reply
Re: [RedRum] Sorting a database In reply to
the default is as you mention above, be in my application I require the sort to be by date db_utils.pl says

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.).

#

so as I am not a programmer can any please inform me on how I can can the variables to achieve the desired effect, an help will be greatly appreciated