在FlexXMLListCollection中如何对XML的子元素进行排序?

在FlexXMLListCollection中如何对XML的子元素进行排序?,xml,apache-flex,actionscript-3,Xml,Apache Flex,Actionscript 3,如何在XML列表集合中按类别名称对以下XML进行排序 <item id="8" title="Sprouts"> <categories> <category name="Produce"/> </categories> <tags/> </item> <item id="7" title="Steak"> <categories> <category name=

如何在XML列表集合中按类别名称对以下XML进行排序

<item id="8" title="Sprouts">
  <categories>
    <category name="Produce"/>
  </categories>
  <tags/>
</item>
<item id="7" title="Steak">
  <categories>
    <category name="Meats"/>
  </categories>
  <tags/>
</item>
<item id="1" title="Apple">
  <categories>
    <category name="Fruits"/>
  </categories>
  <tags/>
</item>

不要使用SortField;使用compareFunction可以深入到XML中,以访问要排序的实际属性。我不能使用比较功能。它必须是SortField()name属性;因为我99%肯定这就是你问题的解决办法。为什么不能使用比较函数?我以前没有注意到,但您没有指定项目的排序方式。凭身份证?按头衔?按类别名称?
var sort:Sort = new Sort();
var sortField:SortField = new SortField();
sort.fields = [sortField];
myCollection.sort = sort;