Google Groups Home
Help | Sign in
ordering by an int has strange behaviour...
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Aaron Vegh  
View profile
 More options Dec 17 2005, 8:28 am
From: Aaron Vegh <aaronv...@gmail.com>
Date: Sat, 17 Dec 2005 08:28:36 -0500
Local: Sat, Dec 17 2005 8:28 am
Subject: ordering by an int has strange behaviour...
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.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joel  
View profile
 More options Dec 17 2005, 3:51 pm
From: "Joel" <joel...@gmail.com>
Date: Sat, 17 Dec 2005 12:51:14 -0800
Local: Sat, Dec 17 2005 3:51 pm
Subject: Re: ordering by an int has strange behaviour...
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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joel  
View profile
 More options Dec 17 2005, 3:52 pm
From: "Joel" <joel...@gmail.com>
Date: Sat, 17 Dec 2005 12:52:13 -0800
Local: Sat, Dec 17 2005 3:52 pm
Subject: Re: ordering by an int has strange behaviour...
return ($service1->sortOrder > $service2->sortOrder);

should read the following instead. sorry for the typo

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron Vegh  
View profile
 More options Dec 17 2005, 3:58 pm
From: Aaron Vegh <aaronv...@gmail.com>
Date: Sat, 17 Dec 2005 15:58:37 -0500
Local: Sat, Dec 17 2005 3:58 pm
Subject: Re: ordering by an int has strange behaviour...
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.

On 12/17/05, Joel <joel...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google