In the past few days, I encountered a problem. The data obtained from the database was converted into an ArrayCollection and bound to the datagrid. As a result, when I clicked the id header, I did not sort the data from small to large, sort by the string ascii code, and then ask ks, the solution found on javaeye needs to customize a sorting method, and then call it, on my computer has been applied successfully, now put this sort out, send out, with link address: http://i5land.javaeye.com/blog/301574
Code of the custom sorting method: 1 public function sortcompare (obj1: Object, obj2: Object): int {
2 var num1: Number = Number (obj1.id. toString ());
3 var num2: Number = Number (obj2.id. toString ());
4 if (num1> num2 ){
5 return 1;
6} else if (num1 <num2 ){
7 return-1;
8} else {
9 return 0;
10}
11}
Then, you only need to change this attribute on the column where you want to redefine the sorting method: sortCompareFunction = "sortcompare"