Hi All, My flex2 DataGrid has got at least 50 columns of type Date.I also have list which opens when use select a context menu item ,in this list user can select any no of columns on which he wants multiple sorting to be happen.
Lets say user has selected 5 Columns for multi sorting,I create 5 sortField with compareFunction in loop as follows var sortFieldArray:Array = new Array(); for(var dataField in selectedColumnArray){ var field:SortField = new SortField(dataField ); field.compareFunction = function(itemA:Object,itemB:Object):int{ var dateA:Date =itemA[dataField ] ; var dateB:Date =itemB[dataField ] ; ..... } sortFieldArray.push(field); } Problem which I have been facing is ,local var dataField is always referring to the last value of selectedColumnArray hence sorting is happening based on last column only. I dont want to create separate compareFunction for each column , simply because at compilation time I dont know about the no of column which user can choose to participate in multipleSorting.And I dont want to create 50 compareFunction with hardcoded dataField name Is it possible to create GENERIC compareFucntion which can take dataField without hard coding ? Please throw some light on this it? Regards, Dharmendra chauhan