apache / royale-compiler

Apache Royale Compiler
https://royale.apache.org/
Apache License 2.0
95 stars 49 forks source link

sortOn is not working in type of ArrayCollection which works in Flash #205

Closed ekumar2 closed 2 years ago

ekumar2 commented 2 years ago

`var arr:ArrayCollection = new ArrayCollection(); arr.addItem({label:"Z", data:"first"}); arr.addItem({label:"C", data:"second"}); arr.addItem({label:"E", data:"third"});

arr.sortOn('label');

expected output - {label:"C", data:"second"}; {label:"E", data:"third"}; {label:"Z", data:"first"}; `

The sortOn works on ArrayCollection and it sorts the object of Arrays based on property passed.

yishayw commented 2 years ago

`var arr:Array = new ArrayCollection(); arr.push({label:"Z", data:"first"}); arr.push({label:"C", data:"second"}); arr.push({label:"E", data:"third"});

Is arr and Array or an ArrayCollection ? Looks like you are declaring it as an Array and assigning to it an ArrayCollection.

greg-dove commented 2 years ago

@ekumar2 Can we consider this closed? As Yishay said, this does appear to be invalid: var arr:Array = new ArrayCollection()

if it was instead:

var arr:Array = [];
arr.push({label:"Z", data:"first"});
arr.push({label:"C", data:"second"});
arr.push({label:"E", data:"third"});
arr.sortOn('label');

...and the results were not correct in this case, then please confirm that is the issue, thanks.

ekumar2 commented 2 years ago

It is ArrayCollection on Updated the information please check.... @greg-dove

joshtynjala commented 2 years ago

I have just confirmed that the ArrayCollection class in Flex did not have a sortOn() method. I think that you are mistakenly remembering the sortOn() method of the Array class.