Gossamer Forum
Home : Products : DBMan : Customization :

First name Last name sort

Quote Reply
First name Last name sort
My author field is like Richard Bandler, John Grinder (it may have other authors)

How can I print it out in alpabetical order on the first author's last name.
Quote Reply
Re: First name Last name sort In reply to
Hmm...I would recommend the following:

1) Add a new field called Other Authors.

Note: Use the script in the Resource Center in the Modification section that will add a new field to your existing database.

2) Then you can sort by the Primary Author field in the following manner:

Search Form:

Code:
<input type="hidden" name="so" value="ascend">
<input type="hidden" name="sb" value="1">

Query String:

Code:
&so=ascend&sb=1

Change 1 to the number of the "primary" author field.

This is the easiest solution.

There are some other tricks with Perl to use the same field and then sort by the first value. But it would be problematic if you are novice programmer.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------





[This message has been edited by Eliot (edited January 07, 2000).]
Quote Reply
Re: First name Last name sort In reply to
If you have a list of autors in each record that you want to sort, you can use this. Also, replace $rec{'author'} with the name of your field. Just insert this code in html.pl right after:
Code:
my (%rec) = @_;



Code:
@authors = split(', ', $rec{'author'});
foreach (@authors) {
$reversed = join(' ', reverse split(' ', $_));
$backward .= "$reversed, ";
}
@forward = split(', ', $backward);
foreach (sort @forward) {
$ct++;
$back_again = join(' ', reverse split(' ', $_),);
($ct == $#forward + 1) ? ($sorted_authors .= $back_again) : ($sorted_authors .= "$back_again, ");
}
Then replace the the $rec{'field_name'} that you normally use with:
Code:
$sorted_authors;

This all assumes that you are not using auto generate.

[This message has been edited by Chris071371 (edited January 07, 2000).]
Quote Reply
Re: First name Last name sort In reply to
Max Cool:

Are you creating a site with information about Neurolinguistic Programming by any chance? If so, I'd love to visit your site when it's available Smile

LoisC
Quote Reply
Re: First name Last name sort In reply to
Yes NLPbooksonline.com - its up but it is still underdevelopment ie only 20 books, and link to amazon.com not in place.
Quote Reply
Re: First name Last name sort In reply to
Max,

Now that I read your post again, I don't think I gave you what you wanted. To do what you want would probably take a hidden field with the first author's last name, kindof like Eliot mentioned above. If you have alot of records in your db, this could all be done automatically with a simple script.



------------------
WFMY-TV Webmaster