[SOLVED] Re: Sort problem
[SOLVED] Re: Sort problem
- Subject: [SOLVED] Re: Sort problem
- From: David Holt <email@hidden>
- Date: Fri, 15 Apr 2005 14:43:58 -0700
And three seconds later I figured it out. I changed
EOSortOrdering timeOrdering =
EOSortOrdering.sortOrderingWithKey("lastPost",
EOSortOrdering.CompareDescending);
to
EOSortOrdering timeOrdering =
EOSortOrdering.sortOrderingWithKey("lastPost.timestamp",
EOSortOrdering.CompareDescending);
Sometimes this stuff is so obvious, it hurts.
David
--
The afternoon knows what the morning never suspected.
Swedish Proverb
from Sunbeams: http://www.thesunmagazine.org
On 15 Apr 2005, at 2:36 PM, David Holt wrote:
Oh dear, I am still banging away at this problem. I think I have
figured out where the problem lies, but I don't know how to solve it.
>From the code below, you'll see that I can find the last post by
sorting on the timestamp of posts in a topic and taking the last
object. What I was stupidly doing was then using the lastpost as the
key to sort the topics, but I don't specify what attribute of the
lastpost I am sorting on. I want to sort on lastpost.timestamp. Can
someone please give me a hint how to do this? Thanks,
David
--
"Insanity is expecting different results from repeating the same
action." -- Anonymous
On 10 Mar 2005, at 1:48 PM, David Holt wrote:
Just in case some code would help:
The lastPost method:
public Post lastPost()
{
NSMutableArray thePosts = (NSMutableArray)
this.valueForKey("posts");
// sort the posts by timestamp
EOSortOrdering timeOrdering =
EOSortOrdering.sortOrderingWithKey("timestamp",
EOSortOrdering.CompareAscending);
NSMutableArray ordering = new NSMutableArray();
ordering.addObject(timeOrdering);
EOSortOrdering.sortArrayUsingKeyOrderArray(thePosts,ordering);
return (Post) thePosts.lastObject();
}
topics sorted by timestamp:
public NSMutableArray theSortedTopics()
{
NSMutableArray theTopics = (NSMutableArray)
this.valueForKey("topics");
// sort the topics by lastPost
EOSortOrdering timeOrdering =
EOSortOrdering.sortOrderingWithKey("lastPost",
EOSortOrdering.CompareDescending);
NSMutableArray ordering = new NSMutableArray();
ordering.addObject(timeOrdering);
EOSortOrdering.sortArrayUsingKeyOrderArray(theTopics,ordering);
return (NSMutableArray) theTopics;
}
On 10 Mar 2005, at 9:23 AM, David Holt wrote:
Hello everyone,
I have a very simple forum with forum>topics>posts. In my Topic EO I
have a method to find the lastPost by sorting the posts in ascending
order and then returning the last object in the array.
In my Forum EO I have a method to sort topics descending on the
lastPost. This works fine except in the case that there is an
attachment to the last post. If there is an attachment (MediumBlob
in mysql) the last post shows up fine in the display on the forum
page, but the topic sort does not seem to take it into consideration
(the topic that includes the attachment doesn't display at the top).
Does anyone have any idea why this might be happening?
David
--
When you sit with a nice girl for two hours you think that it is
only a minute. But when you sit on a hot stove for a minute you
think it's two hours. That's relativity.
Albert Einstein
from Sunbeams: http://www.thesunmagazine.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden