using Flash Builder 4.6 i want to sort an arrayCollection. the array has 2 properties status, and help_id. I want to sort the array to have all "open" statuses at the top, than all the "read", than "onsite", than "complete", and so on. i made a function that does this but i want all the items with the same status to than be sorted by the help_id property highest first low est last.
this is my code to sort the statuses.
[Bindable]protected var myHelp:ArrayCollection = new ArrayCollection();
Sort Function:
function sortFunction(a:Object, b:Object, array:Array = null):int
{
var status:Array = ["open", "read", "onsite","complete", "reopen", "closed"];
var aStatus:Number = status.indexOf(a.status);
var bStatus:Number = status.indexOf(b.status);
if(aStatus == -1 || bStatus == -1)
throw new Error("Invalid value for criticality ");
if(aStatus == bStatus)
return 0;
if(aStatus > bStatus)
return 1;
return -1;
}
var sort:Sort = new Sort();
sort.compareFunction = sortFunction;
myHelp.sort = sort;
myHelp.refresh();
any Help would be much appreciated.