Re: Sort problem
Re: Sort problem
- Subject: Re: Sort problem
- From: David Holt <email@hidden>
- Date: Thu, 10 Mar 2005 13:48:38 -0800
Just in case some code would help:
The lastPost method:
public Post lastPost()
{
NSMutableArray thePosts = (NSMutableArray) "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) "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.
<x-tad-smaller>
Albert Einstein
from Sunbeams: http://www.thesunmagazine.org</x-tad-smaller>
_______________________________________________
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
_______________________________________________
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