Hi. I am very very new to Flex. I created this thread for sorting in Java http://stackoverflow.com/q/15091732/37298
However, I am now trying to do the same thing in ActionScript. I have a Bindable ArrayCollection with Objects that looks like this Code.code : F Code.label: Foo Code.description: The Foo description Then I want to sort exactly as specified in the stackoverflow site. I have around 10 of them which I need in a particular order. I have them defined in an array. Based on the stackoverflow question and some googling, I have come up with the following: private function myCompare(a:Object, b:Object, fields:Array = null):int { if (mostUsed.contains(a.code) && mostUsed.contains(b.code)) { return fields.getItemIndex(a) - fields.getItemIndex(b); } if (mostUsed.contains(a.code)) { return -1; } if (mostUsed.contains(b.code)) { return 1; } var s:Sort = new Sort(); s.fields = fields; var f:Function = s.compareFunction; return f.call(null,a,b,fields); } private var mostUsed:ArrayCollection = new ArrayCollection(["F", "A", "B", "FTR", "HIS", "KEB", "LEG", "MED", "MER", "PEN", "PEO", "PER", "PIN", "PUR", "REF"]); var grunner:ArrayCollection = //getting collection grunner.sort.fields = [new SortField("code")]; grunner.sort.compareFunction = myCompare; grunner.refresh(); But it doesnt work. Any clues? My collection returns empty. Regards Shervin