As ever there's a thousand different ways of doing anything and no
real right or wrong, so there's nothing intrinsically wrong with your
approach.  If you dislike having singleton wrapper classes for your
sorts, then you could just have a map/collection of singleton sort
objects on your application and refer to them where you need them. 
Put them in a singleton map and refer to them by constants to keep
reasonably tidy.

If you feel the idea of singletons is not clean (and I sympathise with
that feeling) then another approach would be to create a
ListCollectionView in your control code, set its source to be your
managed collection, then applying a display specific sort to the
ListCollectionView.

In the control displaying your collections...

private var myViewSpecificNameSort = new Sort();
myViewSpecificNameSort.fields = [new SortField("firstName"),new
SortField("lastName")];

lcv_People.refresh();

<mx:ListCollectionView id="lcv_People" list={MyParty.people}
sort={myViewSpecificNameSort}/>

<mx:TileList dataProvider="{lcv_People}" />

...and the same for the other collections.

This feels cleaner to me and suits my particular predelictions for
separating the display, persistence and the model.

I still haven't seen a compelling reason why you would insist your
data is persisted/handled in sorted order.  It appears that your users
want to see the objects sorted, so sort them when you show them.

Another way of rationalising this is to ask what exactly is your
requirement?  Is it for sorted data or data sorted in the display? 
The former implies a lot about persistence the latter just means you
have to sort the data before displaying it.

--- In flexcoders@yahoogroups.com, Kevin <[EMAIL PROTECTED]> wrote:
>
> Thank you for your thoughts about this.  Through trial and error and  
> a little bit of frustration I am coming to the conclusion that  
> sorting the data in the specific view is perhaps the only way to do  
> it with "Managed" data.  Sorting on the server seems like a waste  
> unless the data never needs to be manipulated on the client.  So with  
> that in mind, here is the specific problem that I have encountered  
> and I am wondering if there is a more elegant solution for.
> 
> Let's say I have an object MyParty which holds the following  
> collections:
> 
> MyParty
> - people (collection of people at the party)
> - events (things that are happening)
> - supplies (..you get the idea)
> 
> I would like to bind these nested collections to components
> 
> <mx:TileList dataProvider="{MyParty.people}" />
> 
> <mx:List dataProvider="{MyParty.supplies}" />
> 
> So where to apply the sort? Temporarily we have created static  
> utility classes that hold the sort for each collection and return the  
> collection so that the sort can be applied via this method
> 
> <mx:TileList dataProvider="{PeopleSort.byName(MyParty.people)}" />
> 
> The people sort class is structured like this
> 
> public class PeopleSort
> {
>               public static function byName(collection: ArrayCollection) :  
> ArrayCollection {
>                       collection.sort = new Sort();
>                       collection.sort.fields = [new 
> SortField("firstName"),new SortField 
> ("lastName")]
>                       collection.refresh();
>                       return collection;
> }
> 
> Somehow this does not seem like the most elegant method, but we can't  
> seem to figure out a better way to do it.
> 
> - Kevin
> 
> 
> 
> 
> On Dec 26, 2007, at 5:12 AM, simonjpalmer wrote:
> 
> >  This shifts the problem from one of
> > persistence and/or data architecture to one of display and the
> > solution for me was more obvious.
>


Reply via email to