var ac:ArrayCollection = new ArrayCollection(); //先加入几条测试数据 ac.addItem( {ID:0,userName:AAA}, {ID:1,userName:CCC}, {ID:2,userName:BBB} ); //定义Sort对象 var sort:Sort = new Sort(); //默认是按照升序排序的 sort.fields = [new SortField("userName")]; //如果按照降序排序,需要修改一下 //sort.fields = [new SortField("userName",true,true)];
//如果先降序(ID)后升序(userName),就这样写,以此类推 //sort.fields = [new SortField("userID",true,true),new SortField("userName")]; //把sort对象指定给ac ac.sort = sort; //执行刷新操作,否则不变 ac.refresh();