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

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -