ordering by an int has strange behaviour...

0 views
Skip to first unread message

Aaron Vegh

unread,
Dec 17, 2005, 8:28:36 AM12/17/05
to Php-Object...@googlegroups.com
Hi there,
I've got a database table where I want to order items by an arbitrary
index called sortorder, which is an int.

When I run the standard query to output the rows and sort by
sortorder, I get some strange results: instead of sorting 1, 2, 3,
etc., it sorts 1, 10, 11, 12, 1, 2, 3, etc. -- it's a 12-item list in
this case.

Any idea why this might be happening? I'm not sure what code to include for you.

Thanks,
Aaron.

Joel

unread,
Dec 17, 2005, 3:51:14 PM12/17/05
to Php Object Generator
Hi Aaron,

in your object class, find the function

CompareXXXBySortOrder

change the function from
return strcmp(strtolower($xxx1->sortOrder),
strtolower($xxx2->sortOrder));

to

return ($service1->sortOrder > $service2->sortOrder);

This is one of the issues right now that occur because the object
doesn't have an internal knowledge of the types of its attributes, but
since 1.6 has this attribute=>type map, this should not occur in 1.6.

Hope this helps
joel

Joel

unread,
Dec 17, 2005, 3:52:13 PM12/17/05
to Php Object Generator
return ($service1->sortOrder > $service2->sortOrder);

should read the following instead. sorry for the typo

return ($xxx1->sortOrder > $xxx2->sortOrder);

Aaron Vegh

unread,
Dec 17, 2005, 3:58:37 PM12/17/05
to Php-Object...@googlegroups.com
Awesome, awesome awesome! That worked Joel, thanks very much!

Yet another reason (did we need one?) to look forward to 1.6. I'll be
one of your guinea pigs, no worries. :-)

Cheers,
Aaron.

Reply all
Reply to author
Forward
0 new messages