Reputation: 583
i used array collection sort method like below . but still sorting wrongly . Any other solution for sort date using flex3
public function SortingDate(ArrColl : ArrayCollection, field : String) : void{
var sortA:Sort = new Sort();
sortA.fields=[new SortField(field,false,true,null)];
ArrColl.sort=sortA;
ArrColl.refresh();
}
it's sorting but day only sorting like
31/08/10
30/09/10
28/07/10
Upvotes: 1
Views: 1366
Reputation: 31883
You need to specify a sortCompareFunction on the DataGridColumn you are using for dates.
It looks like this:
dateColumnSortCompareFunc(obj1:Object, obj2:Object) : int {
// here you translate your object into things that can be evaluated
// and return 1 if obj1 > obj2, 0 if they are equal, and -1 if obj1 < obj2
// for example
var d1:Date = new Date(obj1);
var d2:Date = new Date(obj2);
return ( d1.valueOf() > d2.valueOf() ) ? 1 : ( d1.valueOf() < d2.valueOf() ) ? -1 : 0;
}
Upvotes: 1