tags:

views:

543

answers:

0

Hi!!!

i need sort an arraycollection in flex 3 by date.

i try this but i don't understand why doesn't work!


var dataSortField:SortField= new SortField(); dataSortField.name="productDateAdded"; dataSortField.compareFunction=date_sortCompareFunc;

var dataSort:Sort = new Sort(); dataSort.fields = [dataSortField]; productSort.sort = dataSort; productSort.refresh();


private function date_sortCompareFunc(itemA:Object, itemB:Object):int {

            var dateA:Date = new Date(Date.parse(itemA.productDateAdded));
            var dateB:Date = new Date(Date.parse(itemB.productDateAdded));
            return ObjectUtil.dateCompare(dateA, dateB);
        }


productSort is the arraycollection.

thanks in advanced!