actionscript 3 - AS3 - How to find TWO biggest numbers in Array -


was wondering how find 2 biggest numbers in array using as3 , flash. in advance.

if array comprised of numbers, can following:

myarray.sort(array.numeric);  var biggest:number = myarray[myarray.length-1]; var nextbiggest:number = myarray[myarray.length-2]; 

or, sort other direction:

myarray.sort(array.numeric | array.descending); var biggest:number = myarray[0]; var nextbiggest:number = myarray[1]; 

if array comprised of objects have numeric property, can following:

var myarray:array = [{name: "hugh jass", age: 5},{name: "homer simpson", age: 38}];  myarray.sorton( ["age"], [array.numeric]); 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -