Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

NAILED IT!!! Sort order bug!!

Quote Reply
NAILED IT!!! Sort order bug!!
At least I nailed the problem, my feeble attempts to fix it have failed....

It will not be assimilated....

I couldn't understand why the sort order was oddly interrupted... I do now.

The links are selected, and the correct sort order is use. _THEN_ the alternate category links are selected, and the two HASH/Arrays merged.

Code:
sub build_sort_links {
# --------------------------------------------------------
# Merges two array refs into one link list.
#
my ($arr_a, $arr_b) = @_;
my @names = split /,/, $LINKS{build_sort_order};
my @fields = map { $LINKDB->position($_) - 1 } @names;
my @c = sort { lc join ("", @{$a}[@fields]) cmp lc join ("", @{$b}[@fields]) } @{$arr_b}, @{$arr_a};
return \@c;
}

It's this merger that screws it all up!!!

It works (apparantly) if you use a simple sort, but if you chose to sort by:

isNew DESC, Priority DESC, Rating DESC

the output is pseudo random.

I think the only solutions would be to extract them both into a temporary table (unordered is ok), then extract them again using the preferred sort order.

Quote Reply
Re: NAILED IT!!! Sort order bug!! In reply to
i'd rather just make the alternates in the Links database..

sorta like making CategoryID a mutliple select field..

i don't know how it would cause problems though.. it'd be too much trouble redoing too..

------------------
Jerry Su
Links SQL Licensed
------------------
Quote Reply
Re: NAILED IT!!! Sort order bug!! In reply to
I was hoping to get the mysql server to do the sort, but was unable to do it without resorting to temp tables (something I didn't really want to do), but haven't been able to come up with the SQL to do it.

If anyone sees any other ideas, I'd love to hear them.

I suppose we could make a field in links called AlternateCategory that is just a text field with a separated list of category id's. Drop the alt table all together. Very un -sql'ish though. I'll have to check into this some more. I'm not sure where the joins are very important.

Cheers,

Alex

Quote Reply
Re: NAILED IT!!! Sort order bug!! In reply to
OracleDB can do this.. i forgot what the thing was called though.. but it can get data from two tables combine them and sort them according to a field..



------------------
Jerry Su
Links SQL Licensed
------------------
Quote Reply
Re: NAILED IT!!! Sort order bug!! In reply to
With this layout:

Table A
ID
CID
Name

Table B
AID
CID

We want to get a list of all records that have CID = somevalue, and order it by Name. What would be the SQL call for that?

Cheers,

Alex
Quote Reply
Re: NAILED IT!!! Sort order bug!! In reply to
What about:

Select * from Table_A,Table_B where Table_A.CID=Table_B.CID

(Or, perhaps Table_A.CID=nn and Table_B.CID=nn)

This would create a joined table containing the ROWS in the A table that have CID fields that match the CID field in the B table.

That means a record something that looks like:

ID | Name | CID | AID

If the Table_B will have multiple AID's, I'm not sure how it will react...

I have not played with joins at all, but this is what I gather from the docs.

The docs are kind of sketchy, but it might be a matter of trial and error to see what results come back.

------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/








Quote Reply
Re: NAILED IT!!! Sort order bug!! In reply to
Alex,

On a related issue -- have you thought about making the categories a real heirarchy, so that a category is a sub-category of another category, and it's _not_ reflected in it's path name?

Right now, to move a category with 100 subcategories, you need to edit 100 entries.

If the category was a subcategory of another, entering new categories would be much easier (just type the name, and select the location) and changes would be easier -- just change the location.

Since you build the hierarchy each time, or when changed, wouldn't this make managing larger sites much easier??

Quote Reply
Re: NAILED IT!!! Sort order bug!! In reply to
I've run into this sort order problem with the categories. Any news on bug fixes for this. My new category builds way at the bottom for some categories and at the top on others. It's strange.

Kevin