コードは問題ありませんが、ボタンのクリック時に数値とアルファベット順の並べ替えが適用される例をいくつか示します。
アルファベット順の並べ替えは、2 つの属性による並べ替えの良い例です。この場合、一次ソートは「姓」で行われ、二次ソートは「姓」で行われます。
数値ソートは非常に柔軟です。ソート フィールドの数値パラメーターにブール値 true を指定すると、ソートは属性を数値にキャストし、数値でソートします。false のブール値を指定すると、組み込みの文字列比較関数が使用されます。各データ項目は、比較前に String() 関数にキャストされます。デフォルト値の null を使用すると、最初のデータ項目が数値または文字列であるかどうかが確認され、その内容に基づいて並べ替えが行われます。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="955" minHeight="600">
<mx:Button label="Sort by first then last name" click="sortItemsByName()"/>
<mx:Button label="Sort by number" click="sortItemsByNumber()"/>
<mx:DataGrid dataProvider="{items}"
width="300"
height="300">
<mx:columns>
<mx:DataGridColumn dataField="number"/>
<mx:DataGridColumn dataField="firstname"/>
<mx:DataGridColumn dataField="lastname"/>
</mx:columns>
</mx:DataGrid>
<mx:ArrayCollection id="items">
<mx:Object number="3" firstname="John" lastname="Brown"/>
<mx:Object number="1" firstname="Kate" lastname="Brown"/>
<mx:Object number="4" firstname="Jeremy" lastname="Ryan"/>
<mx:Object number="5" firstname="Joe" lastname="Wilson"/>
<mx:Object number="2" firstname="Greg" lastname="Walling"/>
</mx:ArrayCollection>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.collections.Sort;
import mx.collections.SortField;
/**
* Sort the arraycollection by the firstname and then the last name
* */
private function sortItemsByName():void{
var srt:Sort = new Sort();
srt.fields = [new SortField("firstname"), new SortField("lastname")];
items.sort = srt;
items.refresh();
}
/**
* Sort the arraycollection numerically
* */
private function sortItemsByNumber():void{
var srt:Sort = new Sort();
srt.fields = [new SortField("number", true, false, true)];
items.sort = srt;
items.refresh();
}
]]>
</mx:Script>
</mx:Application>
sortField の言語リファレンスもここにあります...
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/collections/SortField.html
...そして、データ プロバイダーとコレクションに関する Adobe livedocs リファレンス...
http://livedocs.adobe.com/flex/3/html/help.html?content=about_dataproviders_2.html
...そして、ここに並べ替えとフィルタリングに関する良い livedocs リファレンスがあります...
http://livedocs.adobe.com/flex/3/html/help.html?content=about_dataproviders_4.html