I frequently find it helpful to add a getter at the higher level so I can access the lower level property... For example

public function get childProp():Boolean
{
  return child.prop;
}

Once you do this you can use a sort field on childProp.

hth
Scott

---
Scott Melby
Founder, Fast Lane Software
http://www.fastlanesw.com

On Oct 1, 2008, at 8:29 PM, "kyleashipley" <[EMAIL PROTECTED]> wrote:

I would like to implement a sort on an ArrayCollection of composite
objects. I tried using a SortField, but I have to leave the name
property blank because the data I want to sort on is one level deeper
(object.child.property instead of object.property) than normal.  When
I use a sort field in this manner, the refresh does not sort the
ArrayCollection as expected.

Here's a sample of what I'm talking about:

public function setupSort():Sort
{
var sort:Sort = new Sort();
var onlineSort:SortField = new SortField();
onlineSort.compareFunction = compareFunc;
sort.fields = [ onlineSort, new SortField("name", true) ];
return sort;
}

private function compareFunc(a:Object, b:Object):void
{
if ( a.buddyInfo.online && !b.buddyInfo.online ) return -1;
if ( b.buddyInfo.online && !a.buddyInfo.online ) return 1;
return 0;
}

(for reference, online is a Boolean)

If I call refresh on this list, I expect the online people to be
before the offline, but there is no rhyme or reason to the ordering.

Any suggestions?



Reply via email to