array sortOn

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

ernivan
Posts: 59
Joined: 11 Aug 2010, 14:53

array sortOn

Postby ernivan » 26 Aug 2010, 13:16

hi

I have an array of object like:

myArray=[{name:'joe' , age: 34},
{name:'bob' , age: 22},
{name:'carl' , age: 33},
{name:'bobby' , age: 18},
{name:'rober' , age: 16}]


Actionscript 1 don't support myArray.sortOn('age',Array.NUMERIC) .... ok :)

The doc say that I can mix actionscript and java together.

can I convert myArry to java array , make sortOn in java and then convert java array into actionscript array ?
if yes , how ?
if no , how can I resolve the sortOn problem ?

thanks
ernivan
Posts: 59
Joined: 11 Aug 2010, 14:53

Postby ernivan » 27 Aug 2010, 15:07

ok

I find the soluction in AS 1 , I share it :)

myArray.sort(fSort);

function fSort(a,b) {
if (a.age>b.age) return 1;
else return -1;
}

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 53 guests